Ordenar arquivos por ordem de data de modificação
Colaboração: Rubens Queiroz de Almeida
Data de Publicação: 26 de agosto de 2013
A diretiva -t
do comando ls
ordena os arquivos segundo a data de
modificação, do mais recente para o mais antigo.
$ ls -lt
total 2130696
-rw-r--r-- 1 root root 6143130 Jul 23 08:29 openjdk-6-jre-lib_6b27-1.12.6-1ubuntu0.12.04.2_all.deb
-rw-r--r-- 1 root root 776302 Jul 23 08:29 icedtea-6-jre-cacao_6b27-1.12.6-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 512100 Jul 23 08:29 icedtea-6-jre-jamvm_6b27-1.12.6-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 225938 Jul 16 13:51 openjdk-7-jre_7u25-2.3.10-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 5535264 Jul 16 13:51 openjdk-7-jre-lib_7u25-2.3.10-1ubuntu0.12.04.2_all.deb
-rw-r--r-- 1 root root 515462 Jul 16 13:51 icedtea-7-jre-jamvm_7u25-2.3.10-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 35431328 Jul 16 13:51 openjdk-7-jre-headless_7u25-2.3.10-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 87814 Jul 16 13:48 icedtea-6-plugin_1.2.3-0ubuntu0.12.04.3_amd64.deb
-rw-r--r-- 1 root root 87636 Jul 16 13:48 icedtea-7-plugin_1.2.3-0ubuntu0.12.04.3_amd64.deb
-rw-r--r-- 1 root root 16184 Jul 16 13:48 icedtea-netx_1.2.3-0ubuntu0.12.04.3_amd64.deb
-rw-r--r-- 1 root root 600200 Jul 16 13:48 icedtea-netx-common_1.2.3-0ubuntu0.12.04.3_all.deb
-rw-r--r-- 1 root root 93842 Jan 8 2012 nautilus-dropbox_0.7.1-2_amd64.deb
-rw-r--r-- 1 root root 59046 Nov 30 2011 python-gpgme_0.2-1_amd64.deb
-rw-r--r-- 1 root root 35224 Mai 14 2011 python-pypdf_1.13-1_all.deb
-rw-r--r-- 1 root root 22534 Out 17 2010 libunac1_1.8.0-6_amd64.deb
-rw-r--r-- 1 root root 6406 Out 17 2010 unaccent_1.8.0-6_amd64.deb
Esta é a forma padrão de ordenação. Caso queiramos a listagem na ordem reversa de data de modificação,
acrescentamos a diretiva -r
:
-rw-r--r-- 1 root root 6406 Out 17 2010 unaccent_1.8.0-6_amd64.deb
-rw-r--r-- 1 root root 22534 Out 17 2010 libunac1_1.8.0-6_amd64.deb
-rw-r--r-- 1 root root 35224 Mai 14 2011 python-pypdf_1.13-1_all.deb
-rw-r--r-- 1 root root 59046 Nov 30 2011 python-gpgme_0.2-1_amd64.deb
-rw-r--r-- 1 root root 93842 Jan 8 2012 nautilus-dropbox_0.7.1-2_amd64.deb
-rw-r--r-- 1 root root 600200 Jul 16 13:48 icedtea-netx-common_1.2.3-0ubuntu0.12.04.3_all.deb
-rw-r--r-- 1 root root 16184 Jul 16 13:48 icedtea-netx_1.2.3-0ubuntu0.12.04.3_amd64.deb
-rw-r--r-- 1 root root 87636 Jul 16 13:48 icedtea-7-plugin_1.2.3-0ubuntu0.12.04.3_amd64.deb
-rw-r--r-- 1 root root 87814 Jul 16 13:48 icedtea-6-plugin_1.2.3-0ubuntu0.12.04.3_amd64.deb
-rw-r--r-- 1 root root 35431328 Jul 16 13:51 openjdk-7-jre-headless_7u25-2.3.10-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 515462 Jul 16 13:51 icedtea-7-jre-jamvm_7u25-2.3.10-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 5535264 Jul 16 13:51 openjdk-7-jre-lib_7u25-2.3.10-1ubuntu0.12.04.2_all.deb
-rw-r--r-- 1 root root 225938 Jul 16 13:51 openjdk-7-jre_7u25-2.3.10-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 512100 Jul 23 08:29 icedtea-6-jre-jamvm_6b27-1.12.6-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 776302 Jul 23 08:29 icedtea-6-jre-cacao_6b27-1.12.6-1ubuntu0.12.04.2_amd64.deb
-rw-r--r-- 1 root root 6143130 Jul 23 08:29 openjdk-6-jre-lib_6b27-1.12.6-1ubuntu0.12.04.2_all.deb
O comando find
oferece funcionalidades semelhantes, com mais controle
sobre a quantidade de arquivos exibidos.
Referências
- Linux / Unix: Sort ls Command Output By Last Modified Date and Time
- Man page comando
ls