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 -->
  #6 (permalink)  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
If including the last directory component as well is acceptable then you can do [^/]*/[^/]*$ to get the last and the penultimate directory (#1 and half #2) and then if you trim #1 and the last slash, you get the real answer for #2.

*? is certainly not a plain old grep regular expression.

What's the point of this exercise?
Reply With Quote