Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had many files in a folder in which I accidentally ran rm * before interrupting.

It looks like files starting with a, b, and c are gone, but I am not sure, as I didn't know the name of all the files.

Can I rely on that rm works alphabetically so that I can know exactly which files that have been removed?

share|improve this question
Off topic a bit, but if you are looking to recover the files you can use TestDisk or the solutions given in Where do files go when the rm command is issued? – Karthik T Oct 5 '12 at 4:44
up vote 7 down vote accepted

rm does not necessarily work alphabetically, but it works in the order you supply its arguments (with -r it becomes more complicated, but that doesn't matter here). If you wrote exactly as you said, the * will expand to all file names in an alphabetical manner.

So yes, you have removed files alphabetically.

Try executing

echo *

in a directory to see in which order things show up. This is the same order that rm * would remove the files.

share|improve this answer

Yes they work alphabetically..

you can use strace command to check the sequence and how your kernel is working internally. Below is the strace command I used for rm command it translate * to alphabetic sequence.$ strace rm -rf *

execve("/bin/rm", ["rm", "-rf", "a.txt", "b.txt", "c.txt", "d.txt"], [/* 43 vars */]) = 0

<--I have clipped the output-->

Where ever * is there, your bash shell will try to give all the combinations in this order. Some other commands which support this are cp, mv, find etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.