Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > spaces in unix

spaces in unix
Thread Tools
surfacto
Dedicated MacNNer
Join Date: Oct 2001
Location: California
Status: Offline
Reply With Quote
Dec 9, 2001, 03:45 PM
 
Bare with me fellas, I'm a mac user who is new to unix...
What do I do about spaces is filenames? Is there a keystroke that means "space"? Thanks.
jc
     
Earth Mk. II
Mac Elite
Join Date: Feb 2001
Location: Washington, DC
Status: Offline
Reply With Quote
Dec 9, 2001, 04:08 PM
 
you can put the filename in quotes (i.e. "foo bar") or use the escape character (i.e. foo\ bar)

hope that helps
/Earth\ Mk\.\ I{2}/
     
surfacto  (op)
Dedicated MacNNer
Join Date: Oct 2001
Location: California
Status: Offline
Reply With Quote
Dec 9, 2001, 10:20 PM
 
Thanks!
     
Blister
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
Dec 14, 2001, 01:19 PM
 
Being new to unix, I also have a question about working in the Terminal. How can I deal with files that contains bracket characters [ ] ( ) in the name? For instance, I download a file from one of the binaries newsgroups which contains brackets in its filename. But when I try to use the CLI app unrar to extract, it can't see the file. There must be a way to deal with this situation other than tediously editing the file names in the Finder. I hope!

Btw, I tried enclosing the filename in quotes, but that doesn't work.
     
Jelle Monkmater
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status: Offline
Reply With Quote
Dec 14, 2001, 01:26 PM
 
You should be able to use quotes surrounding the file name to access it wihtout getting error messages, so I don't fully understand what's wrong here.

Anyway, an alternative method is to use the escape character '\', so if you have a filename that has brackets like odd(one), you could add the backslash before each bracket like this: odd\(one\). Hope this helps.
The one you love and the one who loves you are never the same person.
     
Mskr
Forum Regular
Join Date: Jun 2001
Location: Savoy, IL USA
Status: Offline
Reply With Quote
Dec 14, 2001, 01:32 PM
 
Originally posted by Blister:
<STRONG>Being new to unix, I also have a question about working in the Terminal. How can I deal with files that contains bracket characters [ ] ( ) in the name? For instance, I download a file from one of the binaries newsgroups which contains brackets in its filename. But when I try to use the CLI app unrar to extract, it can't see the file. There must be a way to deal with this situation other than tediously editing the file names in the Finder. I hope!

Btw, I tried enclosing the filename in quotes, but that doesn't work.</STRONG>
In UNIX, whenever a character is "intercepted" by the shell and interpreted as a special character rather than a character in the filename, you can precede the character with a back-slash ('\') character and "escape" it. This is useful for spaces, tabs, parens, brackets, pipes ('|'), or really any special punctuation characters. For example:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
[batmonkey:~mklahn] root# ls <font color = blue>-1</font>
Applications
Desktop
Documents
GNUstep
Library
Movies
Music
Pictures
Projects
Public
Send Registration
Sites
[foo]
[batmonkey:~mklahn] root# mv [foo] foo
mv: No match.
[batmonkey:~mklahn] root# mv \[foo\] foo
[batmonkey:~mklahn] root# ls <font color = blue>-1</font>
Applications
Desktop
Documents
GNUstep
Library
Movies
Music
Pictures
Projects
Public
Send Registration
Sites
foo
[batmonkey:~mklahn] root#
</font>[/code]

(NOTE: you don't have to be root to do this, it's just that root is the only user on my system right now that uses tcsh. My normal user uses bash.)

Anyway, as you can see, I couldn't move the "[foo]" file without escaping the brackets. Hope this helps...
Software Architect, CodeTek Studios, Inc.

12" AlBook 867 (Combo drive) 640 MB/40 GB (work development machine) -- TiBook 400MHz/384MB/10GB (home machine)
CodeTek VirtualDesktop Pro: Power multitasking! -- DockExtender: Powerful, efficient launcher for Apps, Docs and everything else!
     
Oink
Dedicated MacNNer
Join Date: Jan 2001
Location: the state of the arts?
Status: Offline
Reply With Quote
Dec 14, 2001, 03:08 PM
 
Instead of typing a series of \ , you can drag anything into the terminal window and the full path will be typed out including the proper formating of space. BTW, does any one know anything about the use of bullet in OSX file name?
     
Blister
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
Dec 14, 2001, 08:42 PM
 
Thanks, everyone, for the great tips!

Unfortunately, I still seem to be having problems unraring this file from the Terminal. Here's the filename:

[nla]_mahoromatic_ep_08.rar

If I just type 'unrar e [nla]_mahoromatic_ep_08.rar' in the Terminal, it will say "no match." But when I enclose the filename in quotes or use the ' \ ' before the two brackets, then it tells "no files to extract." However, if I edit all those rar files in the Finder to remove bracket symbols, then it does work! &lt;sigh&gt;
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Dec 15, 2001, 05:55 AM
 
Have you tried using single quotes instead of double quotes? Double quotes allow such things as variable interpolation inside them...
[Wevah setPostCount:[Wevah postCount] + 1];
     
Mskr
Forum Regular
Join Date: Jun 2001
Location: Savoy, IL USA
Status: Offline
Reply With Quote
Dec 17, 2001, 02:31 PM
 
Originally posted by Blister:
<STRONG>Thanks, everyone, for the great tips!

Unfortunately, I still seem to be having problems unraring this file from the Terminal. Here's the filename:

[nla]_mahoromatic_ep_08.rar

If I just type 'unrar e [nla]_mahoromatic_ep_08.rar' in the Terminal, it will say "no match." But when I enclose the filename in quotes or use the ' \ ' before the two brackets, then it tells "no files to extract." However, if I edit all those rar files in the Finder to remove bracket symbols, then it does work! &lt;sigh&gt;</STRONG>
Yeah. Well, as I said, you still need to escape the pipe symbol (the '|' in '[n|a]') as well. So you're name would really be:

\[n\|a\]_mahoromatic_ep_08.rar

BTW, as a suggestion: if you're going to be working with files on the command line, avoid using non-alphanumeric characters (Oh, and '.', '_' and '-' are ok) in your filenames. The UNIX shell you're using (be it csh, tcsh, bash, sh, etc.) will use some of those non-alphanumeric characters as commands or other special operations. Pipe (or '|'), for example, means "send the output of the command before the pipe to the input of the command after the pipe". So, what you're really saying if you type in

unrar e \[n|a\]_mahoromatic_ep_08.rar

is: "run the command 'unrar e \[n' and send its output to the command 'a\]_mahoromatic_ep_08.rar". But, since the unrar command won't work, it won't try to run a\]_mahoromatic_ep_08.rar.


HTH.
Software Architect, CodeTek Studios, Inc.

12" AlBook 867 (Combo drive) 640 MB/40 GB (work development machine) -- TiBook 400MHz/384MB/10GB (home machine)
CodeTek VirtualDesktop Pro: Power multitasking! -- DockExtender: Powerful, efficient launcher for Apps, Docs and everything else!
     
Blister
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
Dec 17, 2001, 04:00 PM
 
Thanks for that further explanation about the pipe symbols and alphanumeric characters...

In this case, though, that character is a lower case 'L', not a pipe. I did try the escape sequence anyway, just to check, and it didn't work. Oh, I also tried single quotes (as suggested above) with no results. The 'PCTools" author finally emailed me back, saying that he couldn't get unrar to work on filenames with brackets either. He suggested I install a shell script that corrects all my filenames. I didn't know how to do that, so instead I'm using a carbon app (Quick Rename) to edit the files. Works great, but I still wish I could do it all from the Terminal.


Originally posted by Mskr:
<STRONG>

Yeah. Well, as I said, you still need to escape the pipe symbol (the '|' in '[n|a]') as well. So you're name would really be:

\[n\|a\]_mahoromatic_ep_08.rar

BTW, as a suggestion: if you're going to be working with files on the command line, avoid using non-alphanumeric characters (Oh, and '.', '_' and '-' are ok) in your filenames. The UNIX shell you're using (be it csh, tcsh, bash, sh, etc.) will use some of those non-alphanumeric characters as commands or other special operations. Pipe (or '|'), for example, means "send the output of the command before the pipe to the input of the command after the pipe". So, what you're really saying if you type in

unrar e \[n|a\]_mahoromatic_ep_08.rar

is: "run the command 'unrar e \[n' and send its output to the command 'a\]_mahoromatic_ep_08.rar". But, since the unrar command won't work, it won't try to run a\]_mahoromatic_ep_08.rar.


HTH.</STRONG>
     
nibeck
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Dec 18, 2001, 04:13 PM
 
If thats the only .rar file in the directory, you can try something like

&gt; unrar *.rar

-Mike
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:16 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,