[Ilugc] [HELP] Extracting directory names using sed

  • From: shakthimaan@xxxxxxxxx (Shakthi Kannan)
  • Date: Fri, 28 Nov 2014 12:11:08 +0530

Hi,

--- On Fri, Nov 28, 2014 at 11:58 AM, Baskar Selvaraj
<baskar at linuxpert.in> wrote:
| I need to extract the last two directory names using sed.  Any
| help/pointers would be appreciated
\--

Use awk:

  $ echo "/pub/videos/nptel/Computer Science and Engineering/Data Structures And
Algorithms" | awk '{print $(NF - 1), $NF}' FS='/' OFS='/'

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com

Other related posts: