I want to know what is the difference between this
ls | xargs rm
ls | xargs -i{} rm {}
Both are working for me
|
|
|
If you have 2 arguments
But
This is because Check this Ideone link to get more idea about it. |
|||||
|
|
With braces it will spawn one Compare
and
|
|||
|
|
|
-i option (equivalent to --replace) creates a sort of placeholder where xargs stores the input it just received. In your second command, the placeholder is "{}", it works like find -exec option. Once defined, xargs will replace this placeholder with the entire line of input. If you don“t like the "{}" name, you can define your own:
In your case, both commands are producing the same result. In the second form, you are just making explicit the default behaviour with the -i option. |
|||
|
|