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.
Asked
Active
Viewed 1.3k times
2 Answers
14
pwd | awk -F/ '{print $(NF-1)}'

Sean Bright
- 118,630
- 17
- 138
- 146
-
1This works great, thank you. You can also do it the otherway to piece together the front part of the path '{ print $1/$2/$3 }' etc. – Aaron Bonner Aug 02 '17 at 13:33