How to get directory path from the absolute path in Unix?

Consider the absolute path as /tmp/Shell_Script/sample_scripts/script.sh

In order to retrieve the complete directory path "/tmp/Shell_Script/sample_scripts", use the below command

dirname /tmp/Shell_Script/sample_scripts/script.sh

The above command will retrieve the complete directory path as below

/tmp/Shell_Script/sample_scripts

Search