GNU/Linux >> Linux Esercitazione >  >> Linux

Come elencare o ordinare tutti i file per dimensione in Linux

Per elencare o ordinare tutti i file in una directory per dimensione, useremo il comando ls, che elencherà i file del computer nei sistemi operativi Unix e simili a Unix.

Lettura correlata :Divertente:SL (Locomotive a vapore) gestisce un treno nel tuo terminale Linux

Quando viene invocato senza alcun argomento, ls elenca i file nella directory di lavoro corrente.

[root@linuxshelltips:~]# ls
anaconda-ks.cfg           bridge-nf-call-iptabley~  fwbackups-1.43.7          ImageMagick-7.0.8-28  remi-release-7.rpm
bridge-nf-call-iptables~  bridge-nf-call-iptablez~  fwbackups-1.43.7.tar.bz2  ImageMagick.tar.gz    report.xml
bridge-nf-call-iptablex~  caddy                     highlight.min.js          initial-setup-ks.cfg  rh6_CloudBerryBackup.rpm

Elenca tutti i file ordinati per dimensione

Per elencare o ordinare tutti i file per dimensione, usa il -S opzione, che dice a ls comando per ordinare l'elenco dei file per dimensione e -h l'opzione rende l'output un formato leggibile dall'uomo.

Nell'output seguente, i file più grandi vengono mostrati all'inizio.

[root@linuxshelltips:~]# ls -lhS

total 52M
-rw-r--r--.  1 root root  37M Sep  3  2018 rh6_CloudBerryBackup.rpm
-rw-r--r--.  1 root root  14M Feb 17  2019 ImageMagick.tar.gz
-rw-r--r--.  1 root root 1.8M Oct  4  2019 fwbackups-1.43.7.tar.bz2
-rw-r--r--   1 root root  98K Jul 23 17:31 highlight.min.js
-rw-r--r--.  1 root root  16K Dec 21  2018 remi-release-7.rpm
drwxrwxr-x   5 root root 4.0K Dec 26  2017 fwbackups-1.43.7
drwxrwxr-x  15 root root 4.0K Feb 17  2019 ImageMagick-7.0.8-28
-rw-r--r--.  1 root root 3.1K Sep 19  2018 report.xml
-rw-r--r--.  1 root root 2.0K Sep  4  2018 initial-setup-ks.cfg
-rw-------.  1 root root 1.9K Jan  1  2018 anaconda-ks.cfg
drwxr-xr-x.  3 root root   47 Sep 19  2018 caddy
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptables~
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptablex~
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptabley~
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptablez~

Elenca tutte le dimensioni dei file in ordine inverso

Puoi anche ordinare i file per dimensione in ordine inverso usando il -r opzione come mostrato.

[user@linuxshelltips:~]# ls -lhrS

total 52M
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptablez~
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptabley~
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptablex~
-rw-r--r--.  1 root root    2 Jan 14  2020 bridge-nf-call-iptables~
drwxr-xr-x.  3 root root   47 Sep 19  2018 caddy
-rw-------.  1 root root 1.9K Jan  1  2018 anaconda-ks.cfg
-rw-r--r--.  1 root root 2.0K Sep  4  2018 initial-setup-ks.cfg
-rw-r--r--.  1 root root 3.1K Sep 19  2018 report.xml
drwxrwxr-x  15 root root 4.0K Feb 17  2019 ImageMagick-7.0.8-28
drwxrwxr-x   5 root root 4.0K Dec 26  2017 fwbackups-1.43.7
-rw-r--r--.  1 root root  16K Dec 21  2018 remi-release-7.rpm
-rw-r--r--   1 root root  98K Jul 23 17:31 highlight.min.js
-rw-r--r--.  1 root root 1.8M Oct  4  2019 fwbackups-1.43.7.tar.bz2
-rw-r--r--.  1 root root  14M Feb 17  2019 ImageMagick.tar.gz
-rw-r--r--.  1 root root  37M Sep  3  2018 rh6_CloudBerryBackup.rpm

Se hai altri suggerimenti, domande o dubbi su Linux? chiedi aiuto nella sezione commenti.


Linux
  1. Come creare file di una certa dimensione in Linux

  2. Come personalizzare gli ambienti utente Linux

  3. Come elencare tutti i pacchetti installati in Linux

  4. Come trovare tutti i file di dimensioni superiori a 1 GB in Linux?

  5. Come elencare tutti gli utenti in un gruppo Linux?

Come visualizzare o elencare i lavori Cron in Linux

Come elencare i file in modo ricorsivo in Linux

Come trovare tutti i caratteri installati in Linux

Come elencare tutti gli utenti di un gruppo in Linux

Come elencare tutti i gruppi in Linux?

Come elencare tutti i file ordinati per dimensione in Linux?