Author Topic: How to change permissions when there's a space in the file name? <SOLVED>  (Read 1013 times)

Offline geezuslvr

  • Jr. Member
  • **
  • Posts: 42
I have a windows program that I want to install using Wine.

The name is Wintac 2011-P

From a console I need to chmod 777 /media/Wintac 2011-P/setup.exe

I can't seem to do this because there's a 'space' between Wintac and 2011-P

what in the world am I gonna do here?

Thank You Everyone for your help... This should probably be in Tips and Tricks as a sticky
« Last Edit: December 13, 2011, 07:22:48 PM by geezuslvr »

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: How to change permissions when there's a space in the file name?
« Reply #1 on: December 10, 2011, 02:00:40 PM »
or use the <tab> key when you typed the first part of the name...

(or even chmod 777 /media/Wintac\ 2011-P/setup.exe should work)


So, now you have three possibilities;  :)

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12791
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: How to change permissions when there's a space in the file name?
« Reply #2 on: December 10, 2011, 02:01:08 PM »
I have a windows program that I want to install using Wine.

The name is Wintac 2011-P

From a console I need to chmod 777 /media/Wintac 2011-P/setup.exe

I can't seem to do this because there's a 'space' between Wintac and 2011-P

what in the world am I gonna do here?

chmod 777 /media/"Wintac 2011-P"/setup.exe

OR

chmod 777 /media/Wintac\ 2011-P/setup.exe

Rubentje beat me to it ;)...

Did anyone noticed it's in the wrong section? :P

Online YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5330
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: How to change permissions when there's a space in the file name?
« Reply #3 on: December 10, 2011, 02:14:47 PM »
I have a windows program that I want to install using Wine.

The name is Wintac 2011-P

From a console I need to chmod 777 /media/Wintac 2011-P/setup.exe

I can't seem to do this because there's a 'space' between Wintac and 2011-P

what in the world am I gonna do here?

A really good example why you should not use "SPACES" in a filename.  Same on winhose




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6372
  • I'm going South
Re: How to change permissions when there's a space in the file name?
« Reply #4 on: December 10, 2011, 06:06:41 PM »
geezuslvr,

Why did you feel you had to change the permissions from the CLI? You could have changed them from within Konqueror or Dolphin instead, and then you wouldn't have had to worry about the spaces.

When you manipulate files with spaces in their names from the command line or in a script, you either have to use the backslash as an escape character before every space, or you have to enclose the filename within quotes. If you do the same thing from a GUI program, you usually don't have to think about the spaces at all.

I know that some very knowledgeable forum members disapprove of spaces in Linux filenames, but nevertheless the spaces aren't actually a problem if you just know how to handle them. I have several hundreds of movies with spaces in their names on my hard drives, and I've never found those spaces problematic in any way.

And by the way, Linux could handle spaces in file names long before Windows could.
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline bicol_willem

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2378
Re: How to change permissions when there's a space in the file name?
« Reply #5 on: December 10, 2011, 08:31:57 PM »
How about just changing the name to one word first?

Online YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5330
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: How to change permissions when there's a space in the file name?
« Reply #6 on: December 10, 2011, 09:55:45 PM »
to rename the file you would still have to escape the space first or put the file name with in quotes. Of course if you are using the command line. I solved this problem long long ago. I simply do not save any file with spaces, on my personal system. I also do not save files with mixed case letters either.




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline Rudge

  • Hero Member
  • *****
  • Posts: 9669
  • I'm Just A Dog.
Re: How to change permissions when there's a space in the file name?
« Reply #7 on: December 10, 2011, 11:35:15 PM »
I think you can just put the file name in single quotes ( 'file with spaces.dog' ) and you will be fine.   


-If you wish to make an apple pie from scratch, you must first invent the universe-  Carl Sagan

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6372
  • I'm going South
Re: How to change permissions when there's a space in the file name?
« Reply #8 on: December 11, 2011, 12:32:23 AM »
I think you can just put the file name in single quotes ( 'file with spaces.dog' ) and you will be fine.  

In most cases you can use either single quotes or double quotes:

Quote
Enclosing characters in single quotes preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.

Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $, `, \, and, when history expansion is enabled, !. The characters $  and `  retain their special meaning within double quotes. The backslash retains its special meaning only when followed by one of the following characters: $, `,  " , \, or <newline>. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an !  appearing in double quotes is escaped using a backslash. The backslash preceding the !  is not removed.

The special parameters *  and @  have special meaning when in double quotes (see PARAMETERS   below).

(From the BASH man page.)
« Last Edit: December 11, 2011, 12:41:33 AM by Bald Brick »
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: How to change permissions when there's a space in the file name?
« Reply #9 on: December 11, 2011, 05:26:13 AM »
to rename the file you would still have to escape the space first or put the file name with in quotes. Of course if you are using the command line. I solved this problem long long ago. I simply do not save any file with spaces, on my personal system. I also do not save files with mixed case letters either.


+1
no spaces in filenames here too (replacing_sometimes_with_underscore_ :))
=> but I do mixed case letters?
Is there a reason to avoid them (I'm not doing it often, but sometimes it happens)...? I'm using CamelCase (http://en.wikipedia.org/wiki/CamelCase) if I need it....
However, I'm not storing two files in the same directory as "textFile.txt" and "TextFile.txt" => Linux can handle that perfectly, but if you copy that folder to a Windows environment  ::) :P
: in that cases I'm using some "rule" in my head, so that I'll never have such situations  8)

Online YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5330
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: How to change permissions when there's a space in the file name?
« Reply #10 on: December 11, 2011, 10:00:00 AM »
to rename the file you would still have to escape the space first or put the file name with in quotes. Of course if you are using the command line. I solved this problem long long ago. I simply do not save any file with spaces, on my personal system. I also do not save files with mixed case letters either.


+1
no spaces in filenames here too (replacing_sometimes_with_underscore_ :))
=> but I do mixed case letters?
Is there a reason to avoid them (I'm not doing it often, but sometimes it happens)...? I'm using CamelCase (http://en.wikipedia.org/wiki/CamelCase) if I need it....
However, I'm not storing two files in the same directory as "textFile.txt" and "TextFile.txt" => Linux can handle that perfectly, but if you copy that folder to a Windows environment  ::) :P
: in that cases I'm using some "rule" in my head, so that I'll never have such situations  8)


I just do it to be consistent.  I don't have to guess wither a file name is or has caps in it.  Perhaps it is a throw back from times long ago. I also do not store two different files with the same name such as your example. Though Linux can deal with it just fine. Just because one can do so, doesn't mean you should, or it is the smartest thing to do.  Of course it is your personal machine and you can do as you please on it.




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: How to change permissions when there's a space in the file name?
« Reply #11 on: December 11, 2011, 12:12:31 PM »
to rename the file you would still have to escape the space first or put the file name with in quotes. Of course if you are using the command line. I solved this problem long long ago. I simply do not save any file with spaces, on my personal system. I also do not save files with mixed case letters either.


+1
no spaces in filenames here too (replacing_sometimes_with_underscore_ :))
=> but I do mixed case letters?
Is there a reason to avoid them (I'm not doing it often, but sometimes it happens)...? I'm using CamelCase (http://en.wikipedia.org/wiki/CamelCase) if I need it....
However, I'm not storing two files in the same directory as "textFile.txt" and "TextFile.txt" => Linux can handle that perfectly, but if you copy that folder to a Windows environment  ::) :P
: in that cases I'm using some "rule" in my head, so that I'll never have such situations  8)


I just do it to be consistent.  I don't have to guess wither a file name is or has caps in it.  Perhaps it is a throw back from times long ago. I also do not store two different files with the same name such as your example. Though Linux can deal with it just fine. Just because one can do so, doesn't mean you should, or it is the smartest thing to do.  Of course it is your personal machine and you can do as you please on it.


I'm always pressing <tab> in the terminal, so no problem there  :D