2014-03-12 17:25:30 +00:00
|
|
|
# xargs
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Execute a command with piped arguments.
|
2014-03-12 17:25:30 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Main use:
|
2014-03-12 17:25:30 +00:00
|
|
|
|
|
|
|
`{{arguments}} | xargs {{command}}`
|
|
|
|
|
2016-01-16 14:12:05 +00:00
|
|
|
- Handle whitespace in arguments:
|
2014-03-12 17:25:30 +00:00
|
|
|
|
|
|
|
`{{arguments_null_terminated}} | xargs -0 {{command}}`
|
|
|
|
|
2015-12-29 15:58:16 +00:00
|
|
|
- delete all files that start with 'M'
|
2014-03-12 17:25:30 +00:00
|
|
|
|
2015-12-29 15:58:16 +00:00
|
|
|
`ls M* | xargs rm`
|
2015-12-29 05:09:35 +00:00
|
|
|
|
2015-12-29 15:58:16 +00:00
|
|
|
- assign incoming arguments to a variable so that they may be used in the middle of a command
|
2015-12-29 05:09:35 +00:00
|
|
|
|
|
|
|
`ls M* | xargs -J % cp % ~/Desktop`
|