Quote:
what confuses me is I can cd to /media/31499* and find myself in /media/31499 my project
|
this outcome is perfectly logical. 'cd' will change to first directory specified, and * will
usually append in the alphabetical order. This way 'space' character is of the greatest priority. I'm not quite sure what you are after, but I'll give it a try.
I presume you want to access another(the only other) directory in the same directory where your project is. This other directory name starts the same way your project name does. You may exclude your project directory using 'grep' and 'ls':
Code:
cd `ls | grep -v 31499\ my\ project | grep 31499*`
'grep' command
s will find all files within listed directory(output of 'ls') that starts with 31499, but doesn't have "31499 my project" in it's name. cd will change directory to first directory listed in the output. There must be more elegant way, but I think this could work, if that's what you wanted.
Pozdrav
PS. Oh yeah, if you are only trying to check whether directory exist or not, maybe you may use grep's -c option, which will display number of files(directories) matching the criteria, or use the return value of 'grep' as mentioned in the man pages:
Quote:
DIAGNOSTICS
Normally, exit status is 0 if selected lines are found and 1 otherwise. But the exit sta-
tus is 2 if an error occurred, unless the -q or --quiet or --silent option is used and a
selected line is found.
|