|
|
spaces in unix
|
|
|
|
Dedicated MacNNer
Join Date: Oct 2001
Location: California
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Washington, DC
Status:
Offline
|
|
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}/
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Oct 2001
Location: California
Status:
Offline
|
|
Thanks!
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Jun 2001
Location: Savoy, IL USA
Status:
Offline
|
|
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!
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jan 2001
Location: the state of the arts?
Status:
Offline
|
|
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?
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
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! <sigh>
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
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];
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Jun 2001
Location: Savoy, IL USA
Status:
Offline
|
|
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! <sigh></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!
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
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>
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
If thats the only .rar file in the directory, you can try something like
> unrar *.rar
-Mike
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|