awk assistance

Price, Erik eprice at ptc.com
Wed Nov 13 13:30:28 EST 2002


> -----Original Message-----
> From: pll at lanminds.com [mailto:pll at lanminds.com]
> Sent: Wednesday, November 13, 2002 1:04 PM
> To: Price, Erik
> Cc: gnhlug-discuss at gnhlug.org
> Subject: Re: awk assistance 
> 
> 
> 
> In a message dated: Wed, 13 Nov 2002 10:53:45 EST
> "Price, Erik" said:
> 
> >I have a file that contains the redirected output of a big "find" 
> >command.  I want to learn how to quickly scan this file for unique 
> >file names, and while I could write a lengthy Perl one-liner,
> 
> Why must it be lengthy?
> 
> 	find ./ -type f | perl -F'/' -ane  'print "$F[$#F]";'
> 
> seems to do the trick just fine.  And if you want to weed out 
> duplicates pipe the output through 'uniq' with your choice of swiches.

I still haven't finished the Camel Book.  I'm not very good with
Perl's command line switches and, without resorting to a man page,
I still have no idea what the above code does! ;)

My own one-liner would have been lengthy.  It would have gone
something like (untested):

cat findoutput.txt | perl -e \
 'while(<STDIN>){m!([^/]+)$!;print $1}'| uniq


... still learning...


Erik



More information about the gnhlug-discuss mailing list