Assumindo as ferramentas GNU, você terá que fazer algo como
find . -maxdepth 1 -name '*ASD*' -printf '%T@\t%pfiles_by_mtime () {
local pattern=$1
local -n arr=$2
arr=()
while IFS=$'\t' read -rd '' mtime name; do
arr+=("$name")
done < <(
find . -maxdepth 1 -name "$pattern" -printf '%T@\t%pfind . -maxdepth 1 -name '*ASD*' -printf '%T@\t%pfiles_by_mtime () {
local pattern=$1
local -n arr=$2
arr=()
while IFS=$'\t' read -rd '' mtime name; do
arr+=("$name")
done < <(
find . -maxdepth 1 -name "$pattern" -printf '%T@\t%p%pre%' | sort -z -k1.1n
)
}
files_by_mtime '*' myarr
for file in "${myarr[@]}"; do
# do something with the filename
echo ">>>$file"
done
' |
sort -z -k1.1n |
while IFS=$'\t' read -rd '' mtime name; do
# do something with the filename
echo ">>>$name"
done
' | sort -z -k1.1n
)
}
files_by_mtime '*' myarr
for file in "${myarr[@]}"; do
# do something with the filename
echo ">>>$file"
done
' |
sort -z -k1.1n |
while IFS=$'\t' read -rd '' mtime name; do
# do something with the filename
echo ">>>$name"
done
Os aros extras são para manipular qualquer nome de arquivo concebível, como aqueles que contêm caracteres de nova linha.
Para encapsular isso em uma função, eu escreveria:
%pre%Necessário bash verson 4.3 +