2014-03-12 21:25:30 +04:00
|
|
|
# xargs
|
|
|
|
|
2016-01-07 20:31:27 +03:00
|
|
|
> Execute a command with piped arguments.
|
2014-03-12 21:25:30 +04:00
|
|
|
|
2016-01-07 20:31:27 +03:00
|
|
|
- Main use:
|
2014-03-12 21:25:30 +04:00
|
|
|
|
|
|
|
`{{arguments}} | xargs {{command}}`
|
|
|
|
|
2016-05-16 15:47:00 +03:00
|
|
|
- Specific example: delete all files that start with 'M':
|
|
|
|
|
|
|
|
`find . -name 'M*' | xargs rm`
|
|
|
|
|
2016-01-16 17:12:05 +03:00
|
|
|
- Handle whitespace in arguments:
|
2014-03-12 21:25:30 +04:00
|
|
|
|
|
|
|
`{{arguments_null_terminated}} | xargs -0 {{command}}`
|
|
|
|
|
2016-05-16 09:51:34 +03:00
|
|
|
- Insert arguments at chosen position, using '%' as the placeholder marker:
|
2014-03-12 21:25:30 +04:00
|
|
|
|
2016-05-16 09:51:34 +03:00
|
|
|
`{{arguments}} | xargs -I '%' {{command}} % {{extra_arguments}}`
|