I'm wondering if the two commands (1) rm -rf *o and (2) rm -rf *.o give the same result: both delete the object files.
Moreover why the above commands delete the executable files as well?
I'm wondering if the two commands (1) rm -rf *o and (2) rm -rf *.o give the same result: both delete the object files.
Moreover why the above commands delete the executable files as well?
*
is a shell pattern matching anything except for hidden files.
rm -rf *o
will thus also delete a file called hello
or test.iso
, whereas rm -rf *.o
will only delete files ending in .o
.
By the way, -r
means recursive, i.e. will delete directories too. It should not be present here. You want rm -f *.o
.
I'm wondering if the two commands (1) rm -rf *o and (2) rm -rf *.o give the same result: both delete the object files.
No, they don't give the same result:
o
as well as all directories that end with o
..o
as well as all directories that end with .o
.Moreover why the above commands delete the executable files as well?
Probably because they end with o
(1) or .o
(2).