A simple solution without external commands.
# BASH # What is this directory? fname='txtfile' echo $(dirname "$fname") # output: . echo $(readlink -f "$fname") # output: /home/me/work/txtfile echo $(dirname $(readlink -f "$fname")) # output: /home/me/work
Did you find this post useful?
Remember that this website doesn’t make use of any trackers or analytics or adv so it doesn’t earn from your visits (moreover, it has a minimal environmental impact).