Hello LinuxQuestions world!
I'm still pretty new to linux, and burning through a unix/linux course offered at the local JC. I'm working on an assignment for shell scripting and I need to make a script that displays a bunch of junk (pwd, date, yadda yadda) and then prompts the user to enter a directory so they can view the contents. If it's valid, then it displays the contents. If it isn't then it throws an error message and the script stops. This is done using if, then and else.
The problem is, my script always shoots straight to the else, even if the subdir entered IS a valid subdirectory.
Here's what I have:
echo Today is 'date +%m/%d/%y'
echo "Which Subdirectory would you like to display?"
if test -d $subdir
echo "Sorry, $subdir is not a valid subdirectory! Give it another shot!"
When I run the the script
Today is date +%m/%d/%y
Which Subdirectory would you like to display?
Sorry, Assigment-3 is not a valid subdirectory! Give it another shot!
Can anyone give me a heads up about what I'm fudging here?
Also, cs41s1003 is my "home" folder for the class on our linux server, which is a subdir of home. (home/cs41s1003/Assignment#/yadda/yadda)