I just want to understand the next line of code in the shell. It is used to get the current working directory. I know that the name $(variable) returns a value inside the variable name, but what should $(command) return? Does it return a value after executing a command? In this case, we can use ` to execute the command.
CWD="$(cd "$(dirname $0)"; pwd)"
The same conclusion can be taken from the next line of code also in another version of the shell
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
I can not understand the values โโof $(cd.. and $(dirname .
Can someone help me figure out how this command is executed?
bash shell terminal sh ksh
KItis Aug 01 '13 at 3:49 am
source share