2

I have a line like this in my script:

rm "$TEMP_DIR/*.txt"

It fails with this output:

rm: cannot remove 'temp/*.txt': No such file or directory

I don't understand why doesn't that work. What am I doing wrong?

unfa
  • 1,745

1 Answers1

7

Because you're using quotes in the command, rm thinks you want a filename with a literal * character, it's not expanding that as a wildcard. Try it without the quotes to match all files ending with .txt instead:

rm "$TEMP_DIR"/*.txt
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
unfa
  • 1,745