Results 1 to 6 of 6

Thread: Removinh folder with a space in the name

  1. #1
    Join Date
    Feb 2008
    Beans
    192

    Removinh folder with a space in the name

    Inadvertently, I have created a folder name with a space in the name. (Ubuntu 12.04 LTS updated).

    I now wish to remove that folder and its contents (permissions for asministrator only), but rm does now recognise the "xxxxx yyyyy" folder name. It goes into cyber confiusion attempting to find the folder with the part of the name before the space.

    So I thought, cleverly, that I would simply rename the folder with no space. But when executing the command line instruction to do that, it once again goes off into cyber fairyland looking for the folder with the name of the part before the space.

    Can't rename; can't remove. Looks like I am stuck with that waste of disk space forever. Unless .....

    Any thoughts?

  2. #2
    Join Date
    Jun 2005
    Location
    Toronto, Canada
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Removinh folder with a space in the name

    If the folder's permissions are set such that the administrator (root) is the owner and no-one else has read/write permissions access to remove the directory, then to delete the folder you will need to use the sudo command:
    Code:
    sudo rm "xxxxx yyyyy"
    Make sure you are sitting in the correct directory when you enter the command or you'll have to specify the complete path.

    More info about sudo here.
    Last edited by Toz; December 30th, 2013 at 02:39 AM.

  3. #3
    Join Date
    Apr 2012
    Beans
    6,416

    Re: Removinh folder with a space in the name

    You can escape the space with a backslash, or enclose the whole name in quotes (either single or double quotes will do)

    Code:
    m -rf xxxxx\ yyyyy
    
    rm -rf "xxxxx yyyyy"
    
    rm -rf 'xxxxx yyyyy'
    FYI 'tab completion' is very useful for stuff like this, it will fill in the escape characters provided you type enough of the name to identify it uniquely --> http://tldp.org/LDP/abs/html/tabexpansion.html

  4. #4
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Removinh folder with a space in the name

    Have you tried surrounding the name with single or double quotes?

    DRAT - out typed again... and you even got the escaped version!
    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

  5. #5
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Removinh folder with a space in the name

    Quote Originally Posted by Toz View Post
    If the folder's permissions are set such that the administrator (root) is the owner and no-one else has read/write permissions, then to delete the folder you will need to use the sudo command:
    Nope. That's not how Unix/Linux file permissions are working.

    You don't have to be the owner of a file (directory/regular file/link/pipe/socket/device...) or have write permission on it to rename or delete it! You only need write permission on the directory that contains the file.


    http://content.hccfl.edu/pollock/aun...ermissions.htm

  6. #6
    Join Date
    Jun 2005
    Location
    Toronto, Canada
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Removinh folder with a space in the name

    Quote Originally Posted by sisco311 View Post
    Nope. That's not how Unix/Linux file permissions are working.

    You don't have to be the owner of a file (directory/regular file/link/pipe/socket/device...) or have write permission on it to rename or delete it! You only need write permission on the directory that contains the file.


    http://content.hccfl.edu/pollock/aun...ermissions.htm
    You are correct, I didn't type that out right. My mind and fingers are thinking different things today. I'll edit my post.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •