Quote:
Originally Posted by druuna
It depends on what you want/need to do.
Have a look at this example:
Code:
$ ls -l test*
-rw-r----- 1 druuna druuna 14 dec 14 14:54 test 01
-rw-r----- 1 druuna druuna 14 dec 14 14:55 test02
$ ls test\ 01 | xargs grep "two"
grep: test: No such file or directory
grep: 01: No such file or directory
$ ls test\ 01 | xargs -i grep "two" {}
two
$ ls test02 | xargs grep "two"
two
Or this:
Code:
$ find . -type d -print | xargs echo Directories:
Directories: . ./New ./Temp
$ find . -type d -print | xargs -I {} echo Directories: {}
Directories: .
Directories: ./New
Directories: ./Temp
|
Thanks again for the reply!
I'm sorry I forgot to say I'm using debian wheezy 7.2, maybe different distributions/versions have different contents of 'man xargs'.
According to the following statement in 'man xargs':
Code:
--replace[=replace-str]
-i[replace-str]
This option is a synonym for -Ireplace-str if replace-str is specified, and for -I{} otherwise. This option is deprecated; use -I instead.
'-i' equals to '-I{}', thus I think the following command from the first example:
Code:
ls test\ 01 | xargs -i grep "two" {}
is equals to:
Code:
ls test\ 01 | xargs -I {} grep "two" {}
So I think the usages of '{}' from the following two commands from the two examples are of the same way:
Code:
ls test\ 01 | xargs -i grep "two" {}
find . -type d -print | xargs -I {} echo Directories: {}
So, I still think the '{}' is just a string/identifier to be replaced in a xargs command line.
Expect you reply again.
