extract a specific substring

  • Follow


Hi to all,
I'm an awk newbie.

I have a text file like this:

aaa  /home/smith/subfolder1/filename1.ext1 bbb
ccc  /home/smith/subfolder1/subfolder2/filename2.ext2 ddd
eee  /home/smith/subfolder1/filename3.ext3 fff
::::

I should extract (for further parsing) the filenames above: in other words
the substrings between the LAST slash '/' (excluded) and the last space ' '
(excluded)

filename1.ext1
filename2.ext2
filename3.ext3
:::::

thanks a lot

Marco


0
Reply Marco 5/21/2004 9:33:21 PM


Marco Meoni wrote:

> Hi to all,
> I'm an awk newbie.
> 
> I have a text file like this:
> 
> aaa  /home/smith/subfolder1/filename1.ext1 bbb
> ccc  /home/smith/subfolder1/subfolder2/filename2.ext2 ddd
> eee  /home/smith/subfolder1/filename3.ext3 fff
> ::::
> 
> I should extract (for further parsing) the filenames above: in other words
> the substrings between the LAST slash '/' (excluded) and the last space ' '
> (excluded)
> 
> filename1.ext1
> filename2.ext2
> filename3.ext3
> :::::
> 
> thanks a lot
> 
> Marco
>  

awk -F '[ /]' '{print $(NF-1)}'

Regards,

	Ed.

0
Reply Ed 5/21/2004 9:35:28 PM


1 Replies
468 Views

(page loaded in 0.065 seconds)

Similiar Articles:













7/23/2012 9:45:45 PM


Reply: