May 2017
Beginner
552 pages
28h 47m
English
The xargs command works by accepting input from stdin, parsing the data into individual elements, and invoking a program with these elements as the final command line arguments. By default, xargs will split the input based on whitespace and execute /bin/echo.
Splitting the input into elements based on whitespace becomes an issue when file and folder names have spaces (or even newlines) in them. The My Documents folder would be parsed into two elements My and Documents, neither of which exists.
Most problems have solutions and this is no exception.
We can define the delimiter used to separate arguments. To specify a custom delimiter for input, use the -d option:
$ echo "split1Xsplit2Xsplit3Xsplit4" | xargs -d X split1 split2 ...