xargs - Wikipedia, the free encyclopedia

xargs - Wikipedia, the free encyclopedia

Many UNIX utilities are line oriented. These may work with xargs as long as the lines do not contain ’, “or space. Some of the UNIX utilities can use NUL as record separator (e.g. Perl (requires -0 and \0 instead of \n), locate (requires using -0), find (requires using -print0), grep (requires -z or -Z), sort (requires using -z)). Using -0 for xargs deals with the problem, but many UNIX utilities cannot use NUL as separator (e.g. head, tail, ls, echo, sed, tar -v, wc, which).

But often people forget this and assume xargs is also line oriented, which is not the case (per default xargs separates on newlines and blanks within lines, substrings with blanks must be single or double-quoted).

Written on May 14, 2012