I am trying to get the directory name of this file, which is not located in my current directory:
/home/me/PhD/file.tsv when I run:
dirname /home/me/PhD/file.tsv I get:
/home/me/PhD/ But, I would like to obtain just: PhD
How can I do this?
basename "$(dirname /home/me/PhD/file.tsv)" Notes:
dirname and basename operate purely on strings. It doesn't matter if the path exists.$() is explained here: What is $() in a command?
dirname file.tsvI get.and when I rundirname /home/me/PhD/file.tsvI get/home/me/PhD/