Reputation:
Given a script which sets some arbitrary properties on a dev server, if I wanted to automatically insert the users system name into a path for say log files, how would I go about doing so?
desired output:
/usr/user/logs/log_file
I have tried using whoami
, echo whoami
, echo $USER
, and it fails to give the desired output. Any help would be greatly appreciated.
Upvotes: 0
Views: 76
Reputation: 158030
$USER
should work. Like this:
log_file="/usr/$USER/logs/log_file"
however, whoami
will work too:
log_file="/usr/$(whoami)/logs/log_file"
Upvotes: 1