sbc_compliant: (Default)
[personal profile] sbc_compliant
I was shown xargs the other day as a means of regularizing data for input.

I had a list of hosts in someList, with an unknown number of whitespace before and after each host, on which I wanted to perform someCommand -someFlag.

One of my co-workers told me to skip manually cleaning up the file and just pipe it through xargs.

Then, at my blank look, he explained xargs briefly and keyed the following into my terminal:

for hosts in `cat someList | xargs `; do someCommand -someFlag $hosts; done

Which processed the list. No muss, no fuss. Sweeeeeet.


Unfortunately, the output was rather lengthy. So, I ran it again, piping the output through a grep for the particular field that I needed.

for hosts in `cat someList | xargs `; do someCommand -someFlag $hosts; done | grep someParticularField

Presto.

Shiny!

Date: 2006-10-20 01:42 pm (UTC)
From: [identity profile] snolan.livejournal.com
xargs is indeed, Shiny!

Profile

sbc_compliant: (Default)
sbc_compliant

November 2019

S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 10th, 2026 06:35 am
Powered by Dreamwidth Studios