Eric Lee Eric Lee - 7 months ago 39
Bash Question

BASH - getting UID on shell script does not work

Hi I have a question about bash.

and I'm new to it.

I made a file named "" and its contents is

set -x
echo $UID
echo "$UID"
echo "$(id -u)"

and the result is blank!!
nothing shows up

However, when i just type "echo $UID" on terminal
it shows "1011"

is there anything i missed for bash?

Please help


bash version is 4.3.11 and I typed "sh" to execute.

and the result is

+ echo

+ echo

+ id -u
+ echo 1011



$UID is a Bash variable that is not set under sh, that's may be why it outputs blank lines.

Try bash or make your script executable with chmod u+x, the program defined in shebang will then be used (/bin/bash)