How to get part of path using linux commands

Roman picture Roman · Aug 15, 2011 · Viewed 11.3k times · Source

Need get part of path, for example "/home/server/folder1/rev.1111/bin" Needed part is "rev.1111" I`ll try to parse by PWD & grep commands, but I am newbie on linux and I cant do this.

Answer

Sean Bright picture Sean Bright · Aug 15, 2011
pwd | awk -F/ '{print $(NF-1)}'