tldr/pages/common/xargs.md

20 lines
426 B
Markdown
Raw Normal View History

2014-03-12 17:25:30 +00:00
# xargs
> Execute a command with piped arguments.
2014-03-12 17:25:30 +00:00
- Main use:
2014-03-12 17:25:30 +00:00
`{{arguments}} | xargs {{command}}`
- Specific example: delete all files that start with 'M':
`find . -name 'M*' | xargs rm`
- Handle whitespace in arguments:
2014-03-12 17:25:30 +00:00
`{{arguments_null_terminated}} | xargs -0 {{command}}`
- Insert arguments at chosen position, using '%' as the placeholder marker:
2014-03-12 17:25:30 +00:00
`{{arguments}} | xargs -I '%' {{command}} % {{extra_arguments}}`