Linux Shell script what dirname and ? means?
bash, linux, unix
Solution
The dirname command removes the trailing / component from the NAME and prints the remaining portion. If the NAME does not contain / component then it prints '.' (means current directory)
Dirname Command Example:
Remove the file name from absolute path.
Let say my directory path is /usr/local/bin/add.sh. Now i want to remove /add.sh and display only /usr/local/bin, then we can use the dirname command.
dirname /usr/local/bin/add.sh
/usr/local/bin
NAME
`dirname` - strip non-directory suffix from file name
SYNOPSIS
dirname NAME
dirname OPTION
DESCRIPTION
Print NAME with its trailing /component removed; if NAME contains no /’s, output ‘.’ (meaning the current directory).
Edit: Also, Some characters have special functions in linux commands `?` <-- Matches one character
Source
Problem
Can any body tell me what this command means? ``` selfDir=$(cd "$(dirname "$0")"; pwd) ? ``` I know - `$0` = running script name - `pwd` = current working dir - `cd` = to change dir What I need is what is dirname? and what ? means at end to make this line completely understandable.