The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 05-16-2008
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,873
Code:
perl -nle'm|([^/]*)$| and print $1' input
perl -nle'm|([^/]*)/[^/]*$| and print $1' input
perl -nle'm|/([^/]*/){2}(([^/]*/){2}[^/]*)| and print $2' input
Or just:

Code:
perl -F\/ -anle'print $F[-1]' input
perl -F\/ -anle'print $F[-2]' input
perl -F\/ -anle'print join "/", @F[3..5]' input