[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reverse cut...

From: Bob Proulx
Subject: Re: Reverse cut...
Date: Thu Nov 28 17:38:13 2002
User-agent: Mutt/1.4i

Fabrizio Morbini <address@hidden> [2002-11-27 08:21:25 +0100]:
> Hi, I have a question on the command "cut":
> -For example immagine that I want to select the filename from an absulute 
> path (and the files hasn't all the same depth).
> How I can ask to cut to start to count the delimiter '/' from the end of 
> the string instead of from the start?

I might suggest using awk instead.  -F sets the delimiter.  NF is the
number of fields on a line.  NF-1 would be the second to the last
field on the line.

  echo /one/two/three | awk -F/ '{print $(NF-1)}'

> There are other solution?

You are probably looking for basename.  It was designed for just your

  basename /one/two/three


reply via email to

[Prev in Thread] Current Thread [Next in Thread]