sorting - sort list of files by date in bash -
given text file containing list of files, e.g.
$ cat file_list.txt /var/x/file1.txt /var/y/file2.txt <etc>
how can sort list of files criteria - lastly accessed time, or lastly changed time?
thanks in advance.
you can utilize stat
command sort
this:
while read -r line; stat -c '%y %n' "$line" done < file_list.txt | sort -n | cutting -d ' ' -f2
stat -c '%y %n'
lists time of lastly modification, seconds since epoch followed space , file name sort -n
sorts timestamps , filename numerically cut -d ' ' -f2
prints file names sort's output bash sorting datetime
No comments:
Post a Comment