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