I found a command 'basename'. Man pages are most always confusing. As an example I type... basename <path>. As a result I get the last file name of the path. So now what? What do I do with this result?
I fail to see the use of this command. It tells you what to do but not what to do with the result. Anyone explain? Thank you...
how to use basename command
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
how to use basename command
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: how to use basename command
basename gives you just the file name for a given argument. It's mostly used in scripts where for example you get a list of full paths from some command and you only want to use the file names.
Re: how to use basename command
Ok thanks for that . I thought I was missing the jist of the command. Thanks again
Re: how to use basename command
The complement of basename is dirname.
so returns the result progname
returns the result /usr/share without the trailing slash.
returns /
returns .
returns myMusic
so
Code: Select all
basename /usr/share/progname
Code: Select all
dirname /usr/share/progname
Code: Select all
dirname /usr
Code: Select all
dirname myMusic/
Code: Select all
basename myMusic/