Jadar Posted June 12, 2011 Share Posted June 12, 2011 Hey guys. I am making a shell script to make a folder with space and a timestamp in its name. Then it changes to it. I do this like this: date=`date +%Y-%m-%d-%H:%M:%S` folder="/folder\ withspace-$date" mkdir $folder cd $folder This would, to me, make sense to work. That is not the case here, because when I try this in Terminal to test I get this: $ date=`date +%Y-%m-%d-%H:%M:%S` $ folder="/folder\ withspace-$date" $ sudo mkdir $folder Password: $ ls / [other folders] folder\ So I am really stumped because it also makes another directory in my current directory. What am I doing wrong? Thanks! Link to comment Share on other sites More sharing options...
Airr Posted July 3, 2011 Share Posted July 3, 2011 Hey guys. I am making a shell script to make a folder with space and a timestamp in its name. Then it changes to it. I do this like this: date=`date +%Y-%m-%d-%H:%M:%S` folder="/folder\ withspace-$date" mkdir $folder cd $folder This would, to me, make sense to work. That is not the case here, because when I try this in Terminal to test I get this: $ date=`date +%Y-%m-%d-%H:%M:%S` $ folder="/folder\ withspace-$date" $ sudo mkdir $folder Password: $ ls / [other folders] folder\ So I am really stumped because it also makes another directory in my current directory. What am I doing wrong? Thanks! Try removing the "\" from "/folder\ withspace-$date", and encasing the $folder variable in quotes like "$folder". A. Link to comment Share on other sites More sharing options...
Recommended Posts