Xargs

From Notes_Wiki
Revision as of 04:45, 23 December 2012 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Shell scripting</yambe:breadcrumb> =xargs= '<tt>xargs</tt>' is very useful for running some command using single line from input at a time as parameter. For...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Shell scripting</yambe:breadcrumb>

xargs

'xargs' is very useful for running some command using single line from input at a time as parameter. For example to compress all files using gzip in a folder one can use:

ls -1 | xargs gzip

In this case if the folder has three files 'a.txt', 'b.txt' and 'c.txt' then following three commands would run due to xargs command above:

gzip a.txt
gzip b.txt
gzip c.txt