Cara mengurutkan output perintah ls berdasarkan tanggal

Perintah ls merupakan salah satu perintah dasar linux yang paling sering digunakan. Perintah ls sama fungsinga dengan perintah dir di DOS, yaitu untuk melihat daftar file atau list file. untuk mengurutkan hasil berdasarkan tanggal, bisa digunakan option -lt setelah perintah ls seperti pada contoh berikut:

ls -lt

hasilnya kira-kira sebagai berikut:

root@tutorials.id:/# ls -lt
total 108100
drwxr-xr-x  22 root root      780 Nov  6 06:06 run
drwxrwxrwt   2 root root     4096 Nov  6 06:05 tmp
drwx------   8 root root     4096 Oct 20 15:21 root
drwxr-xr-x  94 root root     4096 Oct 13 13:08 etc
drwxr-xr-x  13 root root     3800 Oct 13 12:33 dev
dr-xr-xr-x 138 root root        0 Oct 13 12:33 proc
dr-xr-xr-x  13 root root        0 Oct 13 12:33 sys
drwxr-xr-x  20 root root     4096 Oct 13 01:46 lib
drwxr-xr-x   2 root root     4096 Oct 13 01:45 lib64
drwxr-xr-x   4 root root     4096 Oct 12 19:48 home
drwxr-xr-x  12 root root     4096 Oct 12 19:21 var
drwx------   2 root root    16384 Apr 19  2014 lost+found
drwxr-xr-x   2 root root     4096 Apr 18  2014 sbin
drwxr-xr-x   3 root root     4096 Apr 18  2014 boot
lrwxrwxrwx   1 root root       33 Apr 18  2014 initrd.img -> boot/initrd.img-3.13.0-24-generic
lrwxrwxrwx   1 root root       30 Apr 18  2014 vmlinuz -> boot/vmlinuz-3.13.0-24-generic
drwxr-xr-x   2 root root     4096 Apr 18  2014 bin
drwxr-xr-x   2 root root     4096 Apr 18  2014 media
drwxr-xr-x   2 root root     4096 Apr 18  2014 opt
drwxr-xr-x   2 root root     4096 Apr 18  2014 srv
drwxr-xr-x  10 root root     4096 Apr 18  2014 usr
drwxr-xr-x   2 root root     4096 Apr 10  2014 mnt
root@tutorials.id:/#

dan jika dikehendaki urutan yang sebaliknya, maka gunakan option -ltr sebagai berikut:

root@tutorials.id:/# ls -ltr
total 108100
drwxr-xr-x   2 root root     4096 Apr 10  2014 mnt
drwxr-xr-x  10 root root     4096 Apr 18  2014 usr
drwxr-xr-x   2 root root     4096 Apr 18  2014 srv
drwxr-xr-x   2 root root     4096 Apr 18  2014 opt
drwxr-xr-x   2 root root     4096 Apr 18  2014 media
drwxr-xr-x   2 root root     4096 Apr 18  2014 bin
lrwxrwxrwx   1 root root       30 Apr 18  2014 vmlinuz -> boot/vmlinuz-3.13.0-24-generic
lrwxrwxrwx   1 root root       33 Apr 18  2014 initrd.img -> boot/initrd.img-3.13.0-24-generic
drwxr-xr-x   3 root root     4096 Apr 18  2014 boot
drwxr-xr-x   2 root root     4096 Apr 18  2014 sbin
drwx------   2 root root    16384 Apr 19  2014 lost+found
drwxr-xr-x  12 root root     4096 Oct 12 19:21 var
drwxr-xr-x   4 root root     4096 Oct 12 19:48 home
drwxr-xr-x   2 root root     4096 Oct 13 01:45 lib64
drwxr-xr-x  20 root root     4096 Oct 13 01:46 lib
dr-xr-xr-x  13 root root        0 Oct 13 12:33 sys
dr-xr-xr-x 138 root root        0 Oct 13 12:33 proc
drwxr-xr-x  13 root root     3800 Oct 13 12:33 dev
drwxr-xr-x  94 root root     4096 Oct 13 13:08 etc
drwx------   8 root root     4096 Oct 20 15:21 root
drwxr-xr-x  22 root root      780 Nov  6 06:06 run
drwxrwxrwt   2 root root     4096 Nov  6 06:10 tmp
root@tutorials.id:/#

Semoga Bermanfaat

Recent search terms:

One Reply to “Cara mengurutkan output perintah ls berdasarkan tanggal”

Tinggalkan Balasan ke Adi nugroho Batalkan balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *