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?

0

1 Answer 1

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

Not the answer you're looking for? Browse other questions tagged .