Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix Command to get file path without basename

I have following file in unix directory

/home/files/myfiles/good.txt

I need to extract the file path alone

Expected output : /home/files/myfiles

Note: I can not use cut operations as the file path is dynamic. I am getting the filename and filepath as single user input to the shell script

like image 265
logan Avatar asked Nov 29 '22 11:11

logan


1 Answers

Try

$ dirname /home/files/myfiles/good.txt
like image 167
mathk Avatar answered Dec 04 '22 05:12

mathk