[Buffalo-pm] Unix Command / Bash Question...

DANIEL MAGNUSZEWSKI dmagnuszewski at mandtbank.com
Fri Jan 27 07:22:59 PST 2006


All,

I wrote a Perl script to parse a file for ip addresses and hostnames,
and to print out in the format of:

$ip,$hostname

There are some duplicates in the list, so I was just using some unix
commands and pipes to rid them from the output. While doing this, I ran
into something interesting. 

If I do:

user at server:/opt/cwscripts# ./dcraudit.pl | uniq | grep -i '10.x.x.x'

I get the output of:

10.x.x.x,router1
10.x.x.x,router1

If I switch the 'uniq' and 'grep' and run:

user at server:/opt/cwscripts# ./dcraudit.pl |  grep -i '10.x.x.x' | uniq

I get the output of:

10.x.x.x,router1

What is the technical reason for this? I assumed that it would work
either way.

Thanks.

-Dan



More information about the Buffalo-pm mailing list