When I run the following as a normal user, everything is fine:
$(dirname `readlink -f $0`)
But after I switched to root, the following error occurred:
readlink: invalid option -- 'b'
Try `readlink --help' for more information.
dirname: missing operand
Try `dirname --help' for more information.
Any ideas? I tried on local Fedora 16 and Amazon EC2, both running bash shell.
Apologize that I did not further illustrate the issue here. Here is the scenario:
Using normal user account:
$ pwd
/home/myuser
$ export MY_DIR=$(dirname `readlink -f $0`)
$ echo MY_DIR
/home/myuser
Using root user account:
# pwd
/root
# export ROOT_DIR=$(dirname `readlink -f $0`)
readlink: invalid option -- 'b'
Try `readlink --help' for more information.
dirname: missing operand
Try `dirname --help' for more information.
# export ROOT_DIR=echo $(dirname `readlink -f -- $0`)
# echo $ROOT_DIR
/root