David Coulson on 26 Jan 2013 13:45:03 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Strange Bash Behavior vis-a-vis Embedded Spaces


Works as expected for me on RHEL6 - Does rm "directory with spaces"/filename work?

[dcoulson@djc-vm1 ~]$ mkdir test\ 1
[dcoulson@djc-vm1 ~]$  touch test\ 1/foo
[dcoulson@djc-vm1 ~]$ stat test\ 1/foo
  File: `test 1/foo'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d    Inode: 657063      Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/dcoulson)   Gid: ( 500/dcoulson)
Access: 2013-01-26 16:43:50.596104308 -0500
Modify: 2013-01-26 16:43:50.596104308 -0500
Change: 2013-01-26 16:43:50.596104308 -0500
[dcoulson@djc-vm1 ~]$  rm "test 1/foo"
[dcoulson@djc-vm1 ~]$ stat test\ 1/foo
stat: cannot stat `test 1/foo': No such file or directory


On 1/26/13 4:13 PM, Casey Bralla wrote:
I recently tried to do a file deletion and got some strange results.

If I did this command:

rm "/directory with spaces/filename" (with quotes around the full path and file
name) the command would error out with a file-not-found error.

However, this command works just fine:

rm /directory\ with\ spaces/filename


I thought quoting the filename would work, but I had to escape the spaces to
make it work.  I find the escape method to be difficult to read, while the quoted
string is very easy.  Hence, I always use the quoted method.

Can anybody explain why the quoted string does not work?

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug