View Single Post
Old 29-Nov-2007, 02:44 AM   #1 (permalink)
Anilrgowda
Administrator
 
Anilrgowda's Avatar

Posts: 18,715
Join Date: Jan 2006
Rep Power: 10 Anilrgowda is on a distinguished road

IM:
Default Extract strings from text files, unix.

Building a bash script. I need to process a large text file with the following sample lines:

./00300000/10000/9000/319981-4.jpg
./00300000/10000/9000/319981-1.jpg
./00300000/10000/0000/310058-1.jpg
./02000000/00000/4000/2004784-1.jpg
./02000000/00000/4000/2004299-1.jpg
./02000000/00000/4000/2004784-4.jpg
./02000000/00000/4000/2004784-3.jpg

I wish to extract just a substring of the filename portion of each line to end up with

319981
319981
310058
2004784
2004299
2004784
2004784

Any _simple_ combination of grep | sed | awk would suffice.

For extra credit: I also need to remove duplicates and sort!


------------------


Anilrgowda is offline   Reply With Quote