The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



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

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,521
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
Reply With Quote