0

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.

1 Answer 1

1

$USER should work. Like this:

log_file="/usr/$USER/logs/log_file"

however, whoami will work too:

log_file="/usr/$(whoami)/logs/log_file"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.