4

I have this command:

rm -rf ~/.quicklock; echo $?
rm -rf ~/.quicklock; echo $?
rm -rf ~/.quicklock; echo $?
rm -rf ~/.quicklock; echo $?

always exits with 0, even if directory does not exist. I am on a Mac. I thought it would exit with 1 if the directory does not exist?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

1 Answers1

6

rm -f does not consider it to be an error if the file does not exist (nor if the directory does not exist, in the case of rm -rf).

man rm says about -f or --force:

ignore nonexistent files and arguments

John Zwinck
  • 239,568
  • 38
  • 324
  • 436