Find the answer to your Linux question:
Results 1 to 8 of 8
How would I remove a file that has a name with non-letter characters in it? Example: hello!.txt When I try to use the "rm" command I get shell errors because ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Nov 2002
    Posts
    420

    removing files


    How would I remove a file that has a name with non-letter characters in it?
    Example: hello!.txt
    When I try to use the "rm" command I get shell errors because of the exclamation point.

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Escape the exclamation mark either by typing hello\!.txt (that's a backslash) or 'hello!.txt' (single quotes, double won't work).

  3. #3
    Just Joined! Sykotik's Avatar
    Join Date
    Mar 2002
    Location
    Cape Town, South Africa
    Posts
    54
    Quote Originally Posted by Dolda2000
    (single quotes, double won't work).
    What? I've always used double quotes without problems. Figures...

  4. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    It usually works, but ! is a very special character. I don't know exactly what it does, though, but it seems to be more internal than ordinary substitutions.

  5. #5
    Just Joined!
    Join Date
    Oct 2002
    Posts
    45

    rm filename with spaces

    Say you created a file with the name
    "dont worry, just looking around!?dont" decided that this wasn't such a good idea, and would like to remove it.

    When I use the "rm" command, the shell tells me that it cannot find this file. I thought that this was because of the exclamation point, but even when I escape the exclamation point with a \ I still have problems. I also tried specifying the path like this: rm /home/users/user/"filename\!"

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Works perfectly for me. Just enclose the file name in single quotes, or tab complete it.

  7. #7
    Linux User
    Join Date
    Jul 2002
    Location
    Daytona Beach, FL
    Posts
    487
    about time someone said tab-complete
    majorwoo

    Quiet brain, or I\'ll stab you with a Q-tip.

  8. #8
    Just Joined! Sykotik's Avatar
    Join Date
    Mar 2002
    Location
    Cape Town, South Africa
    Posts
    54
    Quote Originally Posted by majorwoo
    about time someone said tab-complete
    Let us all bow down before the altar of Tabcompletius and praise the Gods of Shell.

Posting Permissions

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