Bash-检索最后一个修改过的文件,其中包含一些扩展名

Bash-检索最后一个修改过的文件,其中包含一些扩展名,bash,file,search,Bash,File,Search,如何在bash中获取最后一个修改过的文件,并在其上执行一些操作?如果扩展名为,请尝试一下。jpg: last_modified_file="$(find . -type f -name \*.jpg -printf "%T@ %p\0" | awk 'BEGIN {RS="\0";} {if (NR==1){minmtime=$1; $1=""; lastmodified=$0;} else if (minmtime<$1){minmtime=$1; $1=""; lastmodified

如何在bash中获取最后一个修改过的文件,并在其上执行一些操作?

如果扩展名为,请尝试一下。jpg

last_modified_file="$(find . -type f -name \*.jpg -printf "%T@ %p\0" | awk 'BEGIN {RS="\0";} {if (NR==1){minmtime=$1; $1=""; lastmodified=$0;} else if (minmtime<$1){minmtime=$1; $1=""; lastmodified=$0;}} END{print substr(lastmodified,4)}')"

# do something
printf "The last modified file is named %s\n" "${last_modified_file}"

last_modified_file=“$(find.-type f-name\*.jpg-printf”%T@%p\0“| awk'BEGIN{RS=“\0”;}{if(NR==1){minmtime=$1;$1=“;lastmodified=$0;}else if(minmtimestackoverflow.com/help/how-to-ask