I have to write a shell script in linux in which i have to pull the name of the second last folder of the given path. For example:-
/var/www/html/folder1/folder2/folder3
How can i get only the name of second last folder “folder2” using a command?
Note: My shell script is placed at root (/var/www/html)
Using awk:
Alternatively, call
basenameon thedirname.