Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello guys, Please can someone t 1

Status
Not open for further replies.

HIB049

Technical User
Joined
Jan 31, 2003
Messages
19
Location
GB
Hello guys,

Please can someone tell me how to do the following using awk?

I am trying to get the filenames of the following

/a/b/c/d.ksh
/a/b/e.ksh
/a/f/c/d/f/d/i.ksh
/a.ksh

Any help will be of great use

Thks
Ed
 
You need to use NF (Number of fields) to find last field
eg
awk 'BEGIN{FS="/"} {print$(NF)}' list_of_files.txt

HTH Dickie Bird ((:-)))
 
Another one:
awk '{ z = split($0,arr,"/") ; print arr[z] }' filename
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top