I have a list of files that are space separated and I want to use the touch
command to update their timestamps in that order. But when I supply the filenames as arguments, the timestamps get updated in a different order.
touch 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt 10.txt 11.txt 12.txt
After running the command above and running ls -t
(sorting by time modified) I get the following:
1.txt 10.txt 11.txt 12.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
Does supplying arguments to commands not guarantee the execution order? If not, how can I update the timestamps of those files in that specific order?
ls
will show them in alphabetical order, which is what is happening. You probably need to introduce an artificial delay, e. g.for i in {1..12}; do touch ${i}.txt; sleep 1; done
.