I need to do a touch of several files in a directory in reverse alphabetical order, with a 1 second delay. These files have spaces in their names. I've tried this:
ls | sort -r | tr '\012' '\000' | xargs -0 touch
and this:
#!/bin/bash
for i in $(ls -r);
do
touch "$i"
sleep 1
done
but the first makes it too quick and doesn't get what I want (to the files to appear in order in my device), and the second doesn't handle the spaces right.
Any ideas?
Edit: Sorry, forgot to add that it would be great to do this the faster as possible, 'cause if I have to wait 1 second between files, and I have 60+ files, I don't want to wait more than 1 minute. Sorry for the trouble.