I am writing a program in Bash that needs to get the user\'s username.
I have heard of a thing called whoami, but I have no idea what it does or how to use it.
W
For Bash, KornShell (ksh
), sh
, etc. Many of your questions are quickly answered by either:
man [function]
to get the documentation for the system you are using or usually more conveniently:
google "man function"
This may give different results for some things where Linux and Unix have modest differences.
For this question, just enter "whoami" in your shell.
To script it:
myvar=$(whoami)