Mister Rose
Mister Rose

Reputation: 117

rm: cannot remove '–rf': No such file or directory

I have a Bash script that automates creating some SVN folders. In the course of doing so, it creates a temporary directory. When I try to delete that temp directory with the rm -rf command, I get the following error...

rm: cannot remove '–rf': No such file or directory

It seems to think that "-rf" is a file name. The command works fine on the command line.

Here is my script...

#!/bin/bash

if [ $# -lt 1 ]; then
  echo "Usage: $0 reponame1 reponame2 ..."

else
  for var in "$@"
  do
      REPONAME=$var

      mkdir -p ~/temp-$REPONAME/branches
      mkdir ~/temp-$REPONAME/tags
      mkdir ~/temp-$REPONAME/trunk

      svnadmin create $REPONAME
      svn import ~/temp-$REPONAME svn+ssh://[email protected]/home/username/svnrepos/$REPONAME -m "Initial structure"

      rm –rf ~/temp-$REPONAME/
  done
fi

And here is the output

$ ./mkrepo.sh mysvnrepo
[email protected]'s password:
[email protected]'s password:
Adding         /home/username/temp-mysvnrepo/branches
Adding         /home/username/temp-mysvnrepo/tags
Adding         /home/username/temp-mysvnrepo/trunk
Committing transaction...
Committed revision 1.
rm: cannot remove '–rf': No such file or directory
rm: cannot remove '/home/username/temp-mysvnrepo/': Is a directory

Upvotes: 1

Views: 11484

Answers (2)

vjravi
vjravi

Reputation: 86

The '-' in your script in rm –rf is not the one it expects. The correct one is rm -rf.

I hope you can spot the difference.

rm –rf rm -rf

Upvotes: 1

litelite
litelite

Reputation: 2851

You managed to type a unicode "EN DASH"(U+2013) which is not recognised by rm as a normal hyphen "-"(U+002D) so rm thinks it is the beginning of a file name and not of your parameters. They do look alike, but they are not the same for a program. To fix it, just erase it and type it again making sure you take the normal hyphen/minus key.

Upvotes: 13

Related Questions