How to open a file with a space in the name


Results 1 to 8 of 8

Thread: How to open a file with a space in the name

  1. #1
    Join Date
    Apr 2005
    Location
    Fredonia, NY
    Posts
    73

    How to open a file with a space in the name

    i was just wondering, how would you go about opening a folder in the command line if there is a space in the directory name? thanks a lot
    Last edited by je_fro; 07-19-2005 at 09:30 PM.
    linux user #388813

    Gateway SOLO 5300
    Pentium III 750 Mhz
    256 MB RAM
    20 GB HD
    Mandrake 10.1

  2. #2
    Join Date
    Sep 2004
    Location
    /home/
    Posts
    1,204
    this is probaly going to get locked because you did not follow the posting guidelines.

    and you use a \ in the name

    soule
    Anarchism is founded on the observation that since few men are wise enough to rule themselves, even fewer are wise enough to rule others. - Edward Abbey

    IRC #linuxn00b

    Support your Distro.
    Slackware Store
    Archlinux Schwag

  3. #3
    Join Date
    Nov 2002
    Location
    Dayton, OH
    Posts
    986
    Or enclose it in " marks.
    "After all you've seen, after all the evidence, why can't you believe?"

    IBM Thinkpad T21
    750 Mhz P3, 128 MB PC100 RAM, CD-ROM, 10 GB IDE HDD
    Ubuntu 9.04 Minimal

  4. #4
    Join Date
    Dec 1999
    Location
    Fargo, ND
    Posts
    1,816
    I usually just press <Tab>.
    Knute

    You live, you die, enjoy the interval!

  5. #5
    Join Date
    Aug 2002
    Location
    Delaware
    Posts
    4,285
    Not gonna close it since it already got answered, but they're right. Please read the posting guidelines which are at the top of each forum.
    irc.freenode.net #justlinux The Not So Official JL IRC Channel.
    ¤ Debian ¤ Apt-Get ¤

  6. #6
    Join Date
    Feb 2003
    Location
    London
    Posts
    1,022
    In general, Unix/Linux cmds don't like names with spaces in, although you can use either of the above suggestions to cope ...
    Personally I'd rename the file/dir if at all possible, even if it means altering other scripts that have it hardcoded. Otherwise you'll come up against this on a freq basis.
    Cheers
    Chris

  7. #7
    Join Date
    Apr 2005
    Location
    Fredonia, NY
    Posts
    73
    well the only reason i ask, is because if im running windows, and i need to boot into knoppix to get into the computer, and i want to get a document stored in "My Documents" i didnt know how to, but now i do, and im very greatful for everyones help!
    Last edited by hurleyint1386; 07-20-2005 at 03:41 AM. Reason: spelling error
    linux user #388813

    Gateway SOLO 5300
    Pentium III 750 Mhz
    256 MB RAM
    20 GB HD
    Mandrake 10.1

  8. #8
    Join Date
    May 2003
    Posts
    1,241
    While we're on this topic, I've saved a lot of time, headaches, and escape-character punching with the following script.

    Code:
    #!/bin/sh
    
    # Renames all the files in the current directory to lowercase and
    # replaces spaces with underscores. 
    
    for i in *; do
            echo mv "$i" `echo "$i" | tr ' ' '_' | tr '[:upper:]' '[:lower:]'`
    done
    
    echo
    echo "Enter to accept:"
    echo
    read foo
    
    for i in *; do
            mv -v "$i" `echo "$i" | tr ' ' '_' | tr '[:upper:]' '[:lower:]'`
    done
    Pretty rough, even for a five minute job, but it works.

Posting Permissions

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