[英]BASH script : list all files including subdirectories and sort them by date
I have a bash script: 我有一个bash脚本:
for entry in "/home/pictures"/*
do
echo "ls -larth $entry"
done
It must be a bash script, because some other software (Jenkins) will call it . 它必须是bash脚本,因为其他一些软件(Jenkins)会调用它。
尝试查找。
find /home/pictures -type f -exec ls -l --full-time {} \; | sort -k 6
If there are no newlines in file names use: 如果文件名中没有换行符,请使用:
find /home/pictures -type f -printf '%T@ %p\n'|sort -n
If you can not tolerate timestamps in output, use: 如果您不能容忍输出中的时间戳,请使用:
find /home/pictures -type f -printf '%28T@ %p\n' | sort -n | cut -c30-
If there is possibility of newlines in file name , and , if you can make the program that consumes the output accept null terminated records, you can use: 如果文件名 和中 可能有换行符 , 并且可以使使用输出的程序接受空终止记录,则可以使用:
find /home/pictures -type f -printf '%T@,%p\0' | sort -nz
For no timestamps in output, use: 对于没有时间戳记的输出,请使用:
find /home/pictures -type f -printf '%28T@ %p\0' | sort -nz | cut -zc30-
PS I have assumed that you want to sort by last modification time. PS我假设您要按上次修改时间排序。
I found out the solution for my question: 我为我的问题找到了解决方案:
find . 找 。 -name * -exec ls -larth {} +
-name * -exec ls -larth {} +
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.