MacResource
How do you deal with a space in a filename in Terminal??? - Printable Version

+- MacResource (https://forums.macresource.com)
+-- Forum: My Category (https://forums.macresource.com/forumdisplay.php?fid=1)
+--- Forum: Tips and Deals (https://forums.macresource.com/forumdisplay.php?fid=3)
+--- Thread: How do you deal with a space in a filename in Terminal??? (/showthread.php?tid=30907)

Pages: 1 2


How do you deal with a space in a filename in Terminal??? - Paul F. - 04-03-2007

OK.. I'm using Apple Remote Desktop to send a terminal command, run as root, to 30 computers.

Example;
chflags nouchg /Users/Shared/Application Aliases/•Games/Deimos Rising
rm -f /Users/Shared/Application Aliases/•Games/Deimos Rising

Unlock the file, and remove the file...
It seems to be choking on the spaces in the directory names...


How do I "phrase" things so it will do what I'm trying to do?

(I'd just go to each computer, but this is an experiment before running the same thing on 130 MORE computers....).


I know I"m close here...
Tips appreciated!


Re: How do you deal with a space in a filename in Terminal??? - Paul F. - 04-03-2007

An example of the output from ARD;

Lab 02 (192.168.69.129)
chflags: /Users/Shared/Application: No such file or directory
chflags: Aliases/•Games/Deimos: No such file or directory
chflags: Rising: No such file or directory


It no likey the space...


Re: How do you deal with a space in a filename in Terminal??? - incognegro - 04-03-2007

put the file or directory name in quotes.


Re: How do you deal with a space in a filename in Terminal??? - microchip13 - 04-03-2007

That'll work, but the more official way to do it is to use a '\' (without the quotes. Just the slash) before the space. It essentially means that anything that comes after it, take it exactly how it is.


Re: How do you deal with a space in a filename in Terminal??? - mattkime - 04-03-2007

dragging the file into the terminal will escape special chars automagically


Re: How do you deal with a space in a filename in Terminal??? - Paul F. - 04-03-2007

Quotes got it...
"\" got it...

Can't really drag it into Terminal the way I'm doing it (using ARD), but I'll keep it in mind!

Thanks guys! You just saved me several hours of visiting 26 classrooms! Big Grin


Re: How do you deal with a space in a filename in Terminal??? - Greg the dogsitter - 04-03-2007

You shouldn't have files or paths with spaces. :-)


Re: How do you deal with a space in a filename in Terminal??? - Paul F. - 04-03-2007

Sure.. I know that NOW.. but I'm stuck with the hand I've been dealt for now Smile


Re: How do you deal with a space in a filename in Terminal??? - elmo3 - 04-03-2007

[quote Greg the dogsitter]You shouldn't have files or paths with spaces. :-)
While we're at it, just stick with 8.3 filenames and you'll be fine no matter what you do.

Living in 1980 is nice, isn't it?

Or is that, Living\ in\ 1980\ is\ nice,\ isnt\ it?


Re: How do you deal with a space in a filename in Terminal??? - AllGold - 04-03-2007

[quote Greg the dogsitter]You shouldn't have files or paths with spaces. :-)
Tell that to Apple. Looked in any of your /Library folders lately? Smile