One bug corrected.
The command does ls -t | head -n on some directories.
-------------------------------------------------
n=18

for a; do
shift
if [[ $a =~ ^[[:digit:]]+$ ]]; then
n=$a
else
# directory list
dl+=("$a"); fi; done

if ((${#dl[*]})); then
for d in "${dl[@]}"; do
echo $d
ls -t "$d" | head -n$n; echo; done
else
# echo $PWD
ls -t | head -n$n; # echo;
fi
One bug corrected. The command does ls -t | head -n on some directories. ------------------------------------------------- n=18 for a; do shift if [[ $a =~ ^[[:digit:]]+$ ]]; then n=$a else # directory list dl+=("$a"); fi; done if ((${#dl[*]})); then for d in "${dl[@]}"; do echo $d ls -t "$d" | head -n$n; echo; done else # echo $PWD ls -t | head -n$n; # echo; fi
0 Comentários 0 Compartilhamentos 87 Visualizações