LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   \ in filename (https://www.linuxquestions.org/questions/slackware-14/%5C-in-filename-127601/)

cblamer 12-20-2003 01:14 PM

\ in filename
 
I have a directory with a space in it, it shows as Program\ Files in shell window, in Konqueror it shows as Program Files. I never saw this before with any other distros i had used, but just wondering if its normal, or whats ging on with it.

thanks
chris

wapcaplet 12-20-2003 01:40 PM

The backslash is there to "escape" the space that follows it. Usually a space is used to separate command-line arguments, like if you were copying "somefile" from, say, "Program Files" to "abc":

cp Program Files/somefile abc

The space would be interpreted incorrectly, thinking that you wanted to copy the file from "Program" to "Files/somefile". Anyhow, the backslash is used to tell bash, or other shells, that the space is part of the filename. The backslash is used for a lot of other things too. It basically means "the character that comes next should be treated literally," or sometimes "treat the next character in some special way." It's also used in some programming languages like C, for characters that you can't type in ASCII (such as \n for newline, \t for tab, etc.)

Longinus 12-20-2003 01:47 PM

well said wapcaplet

most people wouldnt explain all that lol
-like me :D

Tinkster 12-20-2003 01:50 PM

That's normal ... the shell is escaping the " "
for you ... if the shell in other distro's doesn't
do it their defaults suck ;)


Cheers,
Tink

cblamer 12-20-2003 02:01 PM

so basically it will allow me to "cp test.txt /c/Program\ Files" where Redhat (I think it was) made me do "cp test.txt "/c/Program Files" ???

DaOne 12-20-2003 02:32 PM

Quote:

Originally posted by Tinkster
That's normal ... the shell is escaping the " "
for you ... if the shell in other distro's doesn't
do it their defaults suck ;)


Cheers,
Tink

Exactly.

Note: Redhat is no different depending on what you use (ie bash, etc.)

cblamer 12-20-2003 02:40 PM

pretty sure i used bash in redhat, i dont recall ever seeing a \ in a filename with a space. but doesnt really matter as long as i know whats going on now that i do see them :D

i just didnt recal seeing them before. then i setup wine, and i see the directory /c/Program\ Files and i was thinking this dosent look right. i better fins out and make sure what i am doing.

anyways thanks everyone.
chris


All times are GMT -5. The time now is 02:35 AM.