Q. Is rm -rf * removes the files in alphabetically?
Simple answer is yes, the files/folders are removed in alphabetic sequence. I ran strace command to support my answer.
I have 4 files in my dir as shown below
firstname.lastname@example.org:~/scripts/temp/temp$ ls -lrt
-rw-rw-r– 1 surendra surendra 0 Oct 10 23:55 c.txt
-rw-rw-r– 1 surendra surendra 0 Oct 10 23:55 b.txt
-rw-rw-r– 1 surendra surendra 0 Oct 10 23:56 a.txt
-rw-rw-r– 1 surendra surendra 0 Oct 10 23:56 d.txt
When issued rm -rf * along with strace, I can see rm -rf * is converted to rm -rf a.txt b.txt c.txt d.txt irrespective of time stamp they have as shown below.
Strace command output for rm -rf *
email@example.com:~/scripts/temp/temp$ strace rm -rf *
execve(“/bin/rm”, [“rm”, “-rf”, “a.txt”, “b.txt”, “c.txt”, “d.txt”], [/* 43 vars */]) = 0
I have clipped the output of strace command.
From this we can conclude that * always changed to alphabetic sequence for many commands such as rm, cp, mv, find etc.
Latest posts by Surendra Anne (see all)
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018