I have a directory: /home/user/
How can I list every file in this directory (including those in sub directories) and order them by the date that they we
For zsh users, you could also use glob qualifiers (also documented on man zshexpn):
echo *(om)
Where o stands for sort order, up and m stands for last modification time.
This can be useful when used in a for loop or another command:
for file in *(^om); do
[ -e "$file" ] || continue
# do something with file orderer from least recently modified to last modified
done
Or chained with another glob qualifier:
last_modified_file=(*(om[1]))