tldr/pages/common/xargs.md

20 lines
384 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}}`
- Handle whitespace in arguments:
2014-03-12 17:25:30 +00:00
`{{arguments_null_terminated}} | xargs -0 {{command}}`
- delete all files that start with 'M'
2014-03-12 17:25:30 +00:00
`ls M* | xargs rm`
- assign incoming arguments to a variable so that they may be used in the middle of a command
`ls M* | xargs -J % cp % ~/Desktop`