Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
3 xargs usage tips — First published in issue #26

3 xargs tips on the road to CLI mastery

xargs can be used to process output from other commands (such as find) as argument to a new commands. It can come very handy in many cases, here are 3:

1. Finding and deleting .zip files:

$ find . -name "*.zip" -type f -print | xargs /bin/rm -f 

2. Finding all .py files importing ujson:

$ find . -name '*.py' | xargs grep 'import ujson' 

3. Process input from a file here changing permissions on a file list:

$ xargs -a file-list.txt -t -d: chmod -v 644
# -a to tell what file
# -t for grouping
# -d for telling the delimiter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.