Понимание параметров xargs -i и -t - PullRequest
0 голосов
/ 13 мая 2019

что такое -i и -t в этом примере

ls . | xargs -i -t cp ./{} $1

Я понимаю, что это копирует все в текущем каталоге в аргумент, который передается в ($1), но я не понимаю, что делают -i и -t.

приведенный выше пример представляет собой фрагмент в файле сценария bash, если вам интересно аргумент.

1 Ответ

1 голос
/ 13 мая 2019

С man xargs:

   -I replace-str
          Replace occurrences of replace-str in the initial-arguments
          with names read from standard input.  Also, unquoted blanks do
          not terminate input items; instead the separator is the
          newline character.  Implies -x and -L 1.

   -i[replace-str], --replace[=replace-str]
          This option is a synonym for -Ireplace-str if replace-str is
          specified.  If the replace-str argument is missing, the effect
          is the same as -I{}.  This option is deprecated; use -I
          instead.

   -t, --verbose
          Print the command line on the standard error output before
          executing it.

В вашем случае, -i используется без замены-str после него, так что думайте об этом как -I{}. Это означает, что {} в cp ./{} $1 заменяется каждым именем файла для копирования.

...