xargs wtf

Using xargs to back-reference command line args even post-sed/grep/etc.

xargs — at least how I’ve most utilized it — is handy for taking some number of lines as input and doing some work per line. It’s hard to be more specific than that as it does so much else.

ls | grep 'aaa' | sed 'p;s/aaa/bbb/' | xargs -n2 | xargs -L1 bash -c 'mv $0 $1'Whatsitdo?
> mv file_aaa_1 file_bbb_1
> mv file_aaa_2 file_bbb_2
> mv file_aaa_3 file_bbb_3
ls | grep 'aaa' | ...
sed 'p;s/aaa/bbb' | ...
xargs -n2 | ...
xargs -L1 bash -c 'mv $0 $1'

--

--

Software Engineer, Photographer, Prepper. https://www.linkedin.com/in/aarontharris/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store