In: Computer Science
Unix ramdom question.
How do you display a list of files in your current directory, sorted by file size with the largest files at the top.
You can simply do
ls -lS <folder_name> | grep -v '^d'
to list all the files in decreasing order of size
-lS, S tells to sort in descending order
Example:
ls -lS ./ | grep -v '^d'
total 45237
-rwxrwxrwx 1 atriax atriax 34262107 Aug 26 14:44
transactions.csv
-rwxrwxrwx 1 atriax atriax 7340032 Sep 8 13:08 NTUSER.DAT
-rwxrwxrwx 1 atriax atriax 1794048 Jan 21 2019
ntuser.dat.LOG2
-rwxrwxrwx 1 atriax atriax 1572864 Jan 21 2019
ntuser.dat.LOG1
-rwxrwxrwx 1 atriax atriax 524288 Jul 11 15:50
NTUSER.DAT{a5e2f1b0-cf93-11e8-b6a1-802bf91bed62}.TMContainer00000000000000000001.regtrans-ms
-rwxrwxrwx 1 atriax atriax 524288 Jan 21 2019
NTUSER.DAT{a5e2f1b0-cf93-11e8-b6a1-802bf91bed62}.TMContainer00000000000000000002.regtrans-ms
-rwxrwxrwx 1 atriax atriax 148956 Sep 8 19:15 Time
oriented Data Visulaizations.ipynb
-rwxrwxrwx 1 atriax atriax 65536 Jul 11 15:50
NTUSER.DAT{a5e2f1b0-cf93-11e8-b6a1-802bf91bed62}.TM.blf
-rwxrwxrwx 1 atriax atriax 53319 Jun 3 11:00
4bo0yx7larez5e34
-rwxrwxrwx 1 atriax atriax 8736 Aug 6 14:58
a.out
-rwxrwxrwx 1 atriax atriax 4349 Jun 11
16:41 requirements.txt
-rwxrwxrwx 1 atriax atriax 2713 May 31
17:22 10-powerline-symbols.conf.1
-r-xr-xr-x 1 atriax atriax 2130 Sep 6 10:50
ntuser.pol
-rwxrwxrwx 1 atriax atriax 664 Aug 6
14:57 main.c
-rwxrwxrwx 1 atriax atriax 75
Aug 6 14:50 file.txt
-rwxrwxrwx 1 atriax atriax 47
Sep 7 16:29 data.txt
-rwxrwxrwx 1 atriax atriax 20
Jan 21 2019 ntuser.ini