Re: Reverse cut...
[email protected] (Bob Proulx) Thu, 28 Nov 2002 15:37:44 -0700
| Newsgroups | gmane.comp.gnu.textutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
Fabrizio Morbini <[email protected]> [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 case. basename /one/two/three three Bob