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

Kevin Eye eye at buffalo.edu
Fri Jan 27 07:34:44 PST 2006


I use sort and uniq a lot. I found similar problems at one point (uniq
returning duplicates). Some googling found that sort is affected by your
locale and LANG environment variables.

My sort man page (redhat) says:

       ***  WARNING  ***  The locale specified by the environment
       affects sort order.  Set LC_ALL=C to get  the  traditional
       sort order that uses native byte values.

Some google results (search for "uniq sort broken") also suggest setting
LC_ALL=POSIX or unsetting the LANG variable.

I'm not sure why this makes sort behave differently, but maybe it'll help
you.

 - Kevin



On 1/27/06 10:22 AM, "DANIEL MAGNUSZEWSKI" <dmagnuszewski at mandtbank.com>
wrote:

> 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
> 
> _______________________________________________
> Buffalo-pm mailing list
> Buffalo-pm at pm.org
> http://mail.pm.org/mailman/listinfo/buffalo-pm

-- 
Kevin Eye
Web Applications Developer
Marketing and Creative Services
University at Buffalo
330 Crofts Hall
Buffalo, NY 14260
eye at buffalo.edu
phone (716) 645-5000 x1435
fax (716) 645-3765




More information about the Buffalo-pm mailing list