I’m writing a script to remove some files, but I don’t understand how asterisk expansions work. These are my attempts to solve my problem:
rm "$path"*.txt
rm "$path"/*.txt
rm "$path"{*}.txt
rm "$path"'*'
rm "/folder/folder\ with\ spaces/*.txt"
I also tried replacing double quotes (") with single quotes(') and backticks (`). After every script computation, I get an error because the * is not substitute. So now I have two questions:
- Why is the asterisk not expanded?
- What’s the difference between the different quoting character (` ” ‘ …) ?
In single quoted nothing interesting happns. Not even
$-variable expansion. Some of those you’ve tried should work (some depending on the variable content). And, really,*is most likely to be not expanded if there’re no matches. Are you sure you got your names right?