How to get part of a path using linux commands

It is necessary to get part of the path, for example, "/home/server/folder1/rev.1111/bin" The necessary part is "rev.1111" I will try to parse the PWD and grep commands, but I am new to Linux and I cannot do this.

+6
source share
2 answers
pwd | awk -F/ '{print $(NF-1)}' 
+11
source

Using the basename and dirname commands:

 basename $(dirname $(pwd)) 
+10
source

Source: https://habr.com/ru/post/895061/


All Articles