Posts

Showing posts from September, 2016

How to use xargs

xargs The xargs command is used like a loop. Say wa? Let's say you have a command that returns multiple lines like: $ ls -1 file1 file2 file3 Now let's say we want to add a file extension to each file. We could use a for or while loop. But xargs is simpler... ls -1 | xargs -I {} mv {} {}.txt This one liner is easier to type and understand than a traditional while or for loop.

How to use xargs

xargs The xargs command is used like a loop. Say wa? Let's say you have a command that returns multiple lines like: $ ls -1 file1 file2 file3 Now let's say we want to add a file extension to each file. We could use a for or while loop. But xargs is simpler... ls -1 | xargs -I {} mv {} {}.txt This one liner is easier to type and understand than a traditional while or for loop.