Hi, in the Unix bash shell script I am trying to capture who the user running the script is.
What would be a Unix bash shell script/commands so that "me007" (Unix user name) can be replaced with a name of the user running this script?
By the way, this script is called from the .bash_profile
Below is a working Unix script which is intended to delete those unneeded SAS* directories without asking a user too many questions but all files in those directories will be deleted automatically as well. I would like any user to be able to run this script from their .bash_profile file but as you see right now it is not possible to do that because there is a specific user name (me007
) hardcoded in the script.
- a user name on Unix server.
- a directory where all these processes will occur.
for dir in $(find /directory1/tmp -type d -a -user me007 -a -name "SAS*")
echo "Remove $dir (y/n)? "; read YN
[[ $YN = Y || $YN = y ]] && rm -r $dir