Maximum number of Bash arguments != max num cp arguments?

As Ignacio said, ARG_MAX is the maximum length of the buffer of arguments passed to exec(), not the maximum number of files (this page has a very in-depth explanation). Specifically, it lists fs/exec.c as checking the following condition: PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *) / sizeof(void *) And, it seems, you have some additional limitations: On a 32-bit Linux, …

Read more

Unable to have Bash-like C-x-e in Zsh

I’m using it with VIM mode. Basically ESC-v (or simply v if already in command mode) opens the terminal. It is setup by: autoload -U edit-command-line zle -N edit-command-line bindkey -M vicmd v edit-command-line Here is how to setup it in emacs mode: autoload edit-command-line zle -N edit-command-line bindkey ‘^Xe’ edit-command-line Use ‘bindkey -e’ to …

Read more

Bash variable substitution vs dirname and basename

The external commands make some logical corrections. Check the result of the next script: doit() { str=$1 echo -e “string $str” cmd=basename [[ “${str##*/}” == “$($cmd $str)” ]] && echo “$cmd same: ${str##*/}” || echo -e “$cmd different \${str##*/}\t>${str##*/}<\tvs command:\t>$($cmd $str)<” cmd=dirname [[ “${str%/*}” == “$($cmd $str)” ]] && echo “$cmd same: ${str%/*}” || echo …

Read more

gdb backtrace with no user input?

Thanks to Aditya Kumar; acceptable solution: gdb -batch -ex “run” -ex “bt” ${my_program} 2>&1 | grep -v ^”No stack.”$ If the program needs arguments: gdb -batch -ex “run” -ex “bt” –args ${my_program} param1 param2 \ param3 … 2>&1 | grep -v ^”No stack.”$

how to make bash expand wildcards in variables?

A deleted answer was on the right track. A slight modification to your attempt: shopt -s extglob MYDIR=”./images” OTHERDIR=”./images/junk” SUFFIXES=’@(pdf|eps|jpg|svg)’ mv “$MYDIR/”*.$SUFFIXES “$OTHERDIR/” Brace expansion is done before variable expansion, but variable expansion is done before pathname expansion. So the braces are still braces when the variable is expanded in your original, but when the …

Read more