dirname command in Linux with examples

dirname is a command in Linux which is used to remove the trailing forward slahes “/” from the NAME and prints the remaining portion. If the argument NAME does not contains the forward slash “/” then it simply prints dot “.”.

Syntax:

dirname [OPTION] NAME


Options provided by dirname:

  • dirname -zero NAME or dirname --z NAME : This option provides a way to end the line by a null command rather then a new line. Using this the next command will execute on the same line rather than on the next line.
  • dirname --help : It displays help information.
  • dirname --version : It displays version information.


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.