shell - Linux rm -rf * delete orders? -


i thought rm removes files in alphabetically, it's not after executation.

enter image description here

so, 's order of command rm executation?

it's not rm providing sorted nature, it's shell expansion. if type rm *, shell expand like:

rm aaa bbb ccc 

and rm never see * argument. way, i'm not sorted behaviour guaranteed all shells bash, per manpage:

... replaced alphabetically sorted list of filenames matching pattern.

the command rm -rf * strange, hybrid case since, if shell sorts * entries, that's still first level of entries.

hence rm -rf * may expand to:

rm -rf aa_dir bb_dir cc_dir 

but it's totally how rm works internally order of processing of entries under directories (though, obviously, it's safe bet entries in directory deleted before directory itself).

more it'll using readdir() or similar, order things based on how they're stored in directory files rather alphabetical ordering.

in case, order in they're deleted shouldn't matter - they'll deleted, assuming permissions allow.


Comments