Tag Info

New answers tagged

-1

A simpler solution without a catch block using "$origin"/!(.jpg|.png|*.bmp): for file in "$origin"/!(*.jpg|*.png|*.bmp); do mv -- "$file" "$destination" ; done Thanks to @Score_Under For a multi-line script you can do the following (notice the ; before done is dropped): for file in "$origin"/!(*.jpg|*.png|*.bmp); do # don't copy types *.jpg|*.png|*.bmp ...


2

For a more aggressive solution than those previously offered, pull up your kernel source and edit include/linux/binfmts.h Increase the size of MAX_ARG_PAGES to something larger than 32. This increases the amount of memory the kernel will allow for program arguments, thereby allowing you to specify your mv or rm command for a million files or whatever ...


1

With xargs: xargs -a myurls sh -c 'wkhtmltopdf $@ all.pdf'


4

Try: # disable shell filename generation (globbing) # and temporarily save applicable shell state set -f -- "-${-:--}" "${IFS+IFS=\$2;}" "$IFS" "$@" # explicitly set the shell's Internal # Field Separator to only a newline eval "IFS='$(printf \\n\')" # split command substitution into an # arg array at $IFS boundaries while # eliding all blank lines in ...


0

Another approach: wkhtmltopdf $(printf '%s ' $(<myurls)) all.pdf


2

Unfortunately it's not the case with wkhtmltopdf, but many commands provide an option to read arguments from a file (wget -i for example); that's the preferred approach where possible. If whitespace in your file isn't important, command substitution works: wkhtmltopdf $(cat myurls) all.pdf Using xargs would also work with your example, but in general ...


3

The maximum length of the command line is set by the system and is sometimes 128KiB. If you need to remove many, many files, you need to call rm more than once, using xargs: find /var/log -type f -print0 | xargs -0 rm -- (Careful, this will find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type ...


1

Here's a python one-liner. (I'm using python because perl and awk don't have a simple way to get the position of a value in a list.) ps -eo args | grep '/path/to/destiny' | python -c 'x=input().split(); print(x[ x.index("-p")+1 ])' It will work as long as the arguments you're trying to extract do not contain spaces.


2

How about using sed: ps -e -o args | grep -e 'destiny.*UNIX' | sed -e 's/.*-t\s\([A-Z0-9]*\).*/\1/' ps -e -o args | grep -e 'destiny.*UNIX' | sed -e 's/.*-p\s\([A-Z0-9]*\).*/\1/' ps -e -o args | grep -e 'destiny.*UNIX' | sed -e 's/.*-m\s\([A-Z0-9]*\).*/\1/' sed -e 's/.*-t\s\([A-Z0-9]*\).*/\1/' s/search for/replace with/options s is to search. .* matches ...


2

You can use grep: ~$ echo "/path/to/destiny -r -m UNIX -t TCP -p 1501" | grep -oP -- '-t \K[^ ]+' TCP ~$ echo "/path/to/destiny -r -m UNIX -t TCP -p 1501" | grep -oP -- '-p \K[^ ]+' 1501 (you may have/want to use things like \s instead of one space: grep -oP -- '-p\s\K[^\s]+') The -o means "print only the matching", the \K will reset the start. Note ...


5

That is not possible in general because only the command itself knows how to parse its own arguments. Taking your example: /path/to/destiny -r -m UNIX -t TCP -p 1501 -p could be an option that takes no argument (like a boolean: it enables or disables some behaviour) in which case 1501 would be a positional argument (like a filename or something). Or -p ...



Top 50 recent answers are included