[How To]Get Only Directory Path from Full Filename in Unix

[Unix] How To Get Only Directory Path from Full Filename

The dirname command strips the filename from the complete file path and gives only the directory path of the file.
Basically the dirname command prints the directory with its trailing / removed. If there are no /'s in directory path, the output is '.' meaning current directory.

Syntax: dirname <full_file_path>

$ dirname app/msg/financial/report2013.sql
$ dirname report.sql

Vishal Lambe - dirname command
 Also see similar command to strip the directory and give only filename : basename

No comments :

Post a Comment