Quantcast
Viewing all articles
Browse latest Browse all 2

Why is the output of this find -newermt command apparently not in order?

When I run

touch a.txt && sleep 0.1 && \
touch b.txt && sleep 0.1 && \
touch c.txt && sleep 0.1 && \
touch d.txt && sleep 0.1 && \
touch e.txt && sleep 0.1 && \
touch f.txt && sleep 0.1 && \
find -newermt "1 sec ago"

the listing doesn't seem to be in order.

$ touch a.txt && sleep 0.1 && \
> touch b.txt && sleep 0.1 && \
> touch c.txt && sleep 0.1 && \
> touch d.txt && sleep 0.1 && \
> touch e.txt && sleep 0.1 && \
> touch f.txt && sleep 0.1 && \
> find -newermt "1 sec ago"
./d.txt
./f.txt
./a.txt
./c.txt
./b.txt
./e.txt
$ 

The order is reproducible. But why is the order the way it is? I know I can sort the output but the order of the default output just seems odd.

By the way, the same order is generated if -printf '%T@ %p\n' is used:

$ touch a.txt && sleep 0.1 && \
> touch b.txt && sleep 0.1 && \
> touch c.txt && sleep 0.1 && \
> touch d.txt && sleep 0.1 && \
> touch e.txt && sleep 0.1 && \
> touch f.txt && sleep 0.1 && \
> find -newermt "1 sec ago" -type f -printf '%T@ %p\n'
1567346420.7185077410 ./d.txt
1567346420.9305093600 ./f.txt
1567346420.3905052190 ./a.txt
1567346420.6065068740 ./c.txt
1567346420.5025060780 ./b.txt
1567346420.8225085330 ./e.txt
$ 

$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs          tmpfs     785M  1.7M  784M   1% /run
/dev/sda6      ext4      288G   99G  175G  37% /
tmpfs          tmpfs     3.9G   39M  3.8G   1% /dev/shm
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1      vfat      496M   39M  458M   8% /boot/efi
tmpfs          tmpfs     785M     0  785M   0% /run/user/118
tmpfs          tmpfs     785M   28K  785M   1% /run/user/1000
$ 

The filesystem is the default, ext4.


The shell from which these commands were run is bash:

$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>