awk assistance

Steven W. Orr steveo at syslang.net
Wed Nov 13 14:01:57 EST 2002


On Wed, 13 Nov 2002, Price, Erik wrote:
=>> From: pll at lanminds.com [mailto:pll at lanminds.com]
=>> Sent: Wednesday, November 13, 2002 1:04 PM
=>> 
=>> 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...
Everyone starts with the Camel book but everyone soon realizes that it's 
pretty crappy to try to learn from. It's best left as a reference book. 
The BEST book for learing perl that I've found is Object Oriented Perl by 
Damian Conway. 

-- 
-Time flies like the wind. Fruit flies like a banana. Stranger things have -
-happened but none stranger than this. Does your driver's license say Organ
-Donor?Black holes are where God divided by zero. Listen to me! We are all-
-individuals! What if this weren't a hypothetical question? steveo at syslang.net




More information about the gnhlug-discuss mailing list