When to use xargs when piping?

xargs can be used when you need to take the output from one command and use it as an argument to another. In your first example, grep takes the data from standard input, rather than as an argument. So, xargs is not needed. xargs takes data from standard input and executes a command. By default, … Read more

ls: terminated by signal 13 when using xargs

I ran across a similar issue and found this thread on search for an answer: Signal 13 means something is written to a pipe where nothing is read from anymore (e.g. see http://people.cs.pitt.edu/~alanjawi/cs449/code/shell/UnixSignals.htm ). The point here is that the ls command as executed by xargs is still writing output when the following head command … Read more

How to stop xargs on first error?

General method xargs -n 1 sh -c ‘<your_command> $0 || exit 255’ < input Specific case xargs -n 1 sh -c ‘curl –silent –output /dev/null \ –write-out “%{url_effective}: %{http_code}\n” $0 || exit 255’ < pages.txt Explanation For every URL in pages.txt, executes sh -c ‘curl … $0 || exit 255’ one by one (-n 1) … Read more

Is there a grep equivalent for find’s -print0 and xargs’s -0 switches?

Use GNU Grep’s –null Flag According to the GNU Grep documentation, you can use Output Line Prefix Control to handle ASCII NUL characters the same way as find and xargs. -Z –null Output a zero byte (the ASCII NUL character) instead of the character that normally follows a file name. For example, ‘grep -lZ’ outputs … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)