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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pattern Matching etc

Status
Not open for further replies.

danhodges99

IS-IT--Management
Feb 6, 2003
21
GB
Hi,
From a list of directory paths, I need to get only what appears after the last "/" in the path, for example:
From /usr/bin/ftp, I only want "ftp".
From /var/apache/htdocs/project/index.html, I only want "index.html".
Hope this makes sense as it's really been bugging me, I'm guessing there is an awk or sed command that can be used, but I can't find it! Ta.

 
an awk solution:

awk -F/ '{print $NF}' list_of_dirs.file


-jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top