Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   xargs.1p    ( 1 )

создавать списки аргументов и вызывать утилиту (construct argument lists and invoke utility)

Примеры (Examples)

1. The following command combines the output of the
           parenthesized commands (minus the <apostrophe> characters)
           onto one line, which is then appended to the file log. It
           assumes that the expansion of "$0$*" does not include any
           <apostrophe> or <newline> characters.

(logname; date; printf "'%s'\n$0 $*") | xargs -E "" >>log

2. The following command invokes diff with successive pairs of arguments originally typed as command line arguments. It assumes there are no embedded <newline> characters in the elements of the original argument list.

printf "%s\n$@" | sed 's/[^[:alnum:]]/\\&/g' | xargs -E "" -n 2 -x diff

3. In the following commands, the user is asked which files in the current directory (excluding dotfiles) are to be archived. The files are archived into arch; a, one at a time or b, many at a time. The commands assume that no filenames contain <blank>, <newline>, <backslash>, <apostrophe>, or double-quote characters.

a. ls | xargs -E "" -p -L 1 ar -r arch

b. ls | xargs -E "" -p -L 1 | xargs -E "" ar -r arch

4. The following command invokes command1 one or more times with multiple arguments, stopping if an invocation of command1 has a non-zero exit status.

xargs -E "" sh -c 'command1 "$@" || exit 255' sh < xargs_input

5. On XSI-conformant systems, the following command moves all files from directory $1 to directory $2, and echoes each move command just before doing it. It assumes no filenames contain <newline> characters and that neither $1 nor $2 contains the sequence "{}".

ls -A "$1" | sed -e 's/"/"\\""/g' -e 's/.*/"&"/' | xargs -E "" -I {} -t mv "$1"/{} "$2"/{}