-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Usage | ||
|
||
`xargs` is about converting input lines to parameters | ||
|
||
cat pet-names.txt | xargs # All names in a line | ||
cat pet-names.txt | xargs -2 # Only 2 names per line | ||
|
||
find . -print0 | xargs -0 # Only safe way to iterate file paths | ||
|
||
When processing input xargs removes quotes. To prevent this use `-d$'\n'` | ||
|
||
<some command> | xargs -d$'\n' <params> | ||
|
||
|
||
Use `-I` to define a replace pattern in the command specified where you can | ||
insert the passing value multiple times. For example construct a mv command | ||
that renames files: | ||
|
||
find . -print0 | xargs -0 -I{} echo mv {} {}.old |