1 | initial version |
You can use the dirname
command in bash to extract the directory name from a given path.
Syntax:
$ dirname /path/to/file
Example:
$ dirname /home/user/Documents/example.txt
/home/user/Documents
This command will return the directory name from the given path "/home/user/Documents/example.txt". In this case, the output will be "/home/user/Documents".