I'm trying to write a script that prompts the user to type in the name of a directory that is somewhere in their home directory (IE could be a subdirectory) and then searches for that directory and backs it up using tar/gzip.
The problem I'm having is that I can't get bash to properly search for a directory, I tried using "find -d" but I could never get it to work properly with subdirectories.
Here's my current code (sorry for the mess)
#Prompt the user to input the directory name they want backed up.
echo "You pressed Y, Please input the name of the directory you want ba$
#Read the directory name that the user inputs.
#Repeats the directory name back to the user to confirm their choice.
echo "You entered $directoryName";
#Check if the directory exists
if [ -d "$directoryName" ]; then
echo "File exists, Now is processing backup to your home directory";
#Back up the files in the fileExtension path in backup dir.
tar -czf $OUTPUT $backup
The big problem is the above code doesnt actually search through all the users directories and subdirectories for the given directory. Is there any way to do this with "find" or some other method? I'm stuck.