1

I'm trying to rm a directory and its contents, however for whatever reason rm is ignoring escape characters.

In this example, I'm trying to remove the folder Team Fortress 2 from ~/.local/share/Steam/SteamApps/common:

[redacted@host common]$ rm -r Team\ Fortress\ 2/
/usr/bin/rm: cannot remove ‘Team’: No such file or directory
/usr/bin/rm: cannot remove ‘Fortress’: No such file or directory
/usr/bin/rm: cannot remove ‘2/’: No such file or directory

I've also tried wrapping the directory name in quotes:

[redacted@host common]$ rm -r 'Team\ Fortress\ 2/'
/usr/bin/rm: cannot remove ‘Team\\’: No such file or directory
/usr/bin/rm: cannot remove ‘Fortress\\’: No such file or directory
/usr/bin/rm: cannot remove ‘2/’: No such file or directory

Here's the output from rm --version:

rm (GNU coreutils) 8.21
...

Why would this be happening?

11

My first guess would be that rm is a poorly defined function or script, e.g., something like

rm()
{
    /usr/bin/rm -i $1
}

To find out, execute this command:

type rm

If I'm wrong, it will say:

rm is /usr/bin/rm

If I'm right, it will tell you exactly how rm has been redefined.

  • Thanks - I had a function for rm that I had since removed, but I was running the command here in a tmux session that was still using my old .bashrc. rm is now working again. – user183714 Dec 14 '13 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy