Using Select to make a simple directory menu why doesn't it work
For a homework assignment I am trying to make a script that will give the user a list of all his/her directories and allow them to select wich directory they would like to use as the working directory. I have a few extra lines to help me debug and it looks like things are how they need to be to select the directory but you can see in my output that I am still getting the no such file error.
# Directory list test script
# First we go to users home directory
# now we make a select menu loop that will make a list of directories into the menu this will prevent the user from trying to enter in a directory location that is not a directory
select filename in `ls -R | grep ./ | tr "." " " | tr : " "`
do echo "$filename";pwd;cd;cd "~$filename"
[ctrimble@rc02uxas01 ctrimble]$ bash dirtree
1) /backups 3) /CS140U/project 5) /CS140U/TMPDIR 7) /mail
2) /CS140U 4) /CS140U/TMP 6) /Desktop 8) /Mail
dirtree: cd: ~/backups: No such file or directory
Where and why is this not working correctly?