Hi, in the below Unix bash shell script I am trying to solve 3 different issues that I am facing:
- a unique user name on Unix server.
- a directory where all these processes will occur.
for dir in $(find /directory1/tmp -type d -a -user $LOGNAME -a -name "SAS*")
echo "Remove $dir (y/n)? "; read YN
[[ $YN = Y || $YN = y ]] && rm -r $dir
How to disable not necessary exception messages for other user's directories? Directories can be searched and shown only for that particular user who is currently operating in the Unix environment and not for any other users directories.
For example: if someone other Unix user have created a directory that directory shows up as following in the prompt.
find: cannot read dir /directory1/tmp/direcory12: Permission denied
I just don't want to see this prompt message, because it is not my directory and I don't have permissions to delete it anyway.
Currently 'Y' or 'y' are standing for Yes and any other letters, number, or characters are standing for No. How may I narrow these down to just 'y' and 'n' if that is possible?
How may I delete SAS* directories without prompt asking me if I would like to delete sub-directories in that SAS* directory? When a SAS* directory is deleted then all its sub-directories should be deleted as well automatically.
Example of prompt at the login:
find: cannot read dir /directory1/tmp/directory12: Permission denied
Remove /directory1/tmp/SASdir1 (y/n)?
Remove /directory1/tmp/SASdir2 (y/n)?
Remove /directory1/tmp/SASdir2/SASsubdir1 (y/n)?
Remove /directory1/tmp/SASdir2/SASsubdir2 (y/n)?
Any suggestions or comments will be greatly appreciated!