Encontre o espaço total ocupado pelo ISO em FS?

1

Eu quero um script awk para encontrar a soma da saída de

sudo find / -type f -iname *.iso -print0 | xargs -0 du

Apesar de não ser difícil trazer a saída em formato legível para humanos, seria bom se pudesse ser feito em tempo real.

A saída é assim:

ejs@sanctum:/tmp$ sudo find / -type f -iname *.iso -print0 | xargs -0 du
find: ‘/run/user/1000/gvfs’: Permission denied
2696508 /media/ejs/huge390GB/firefox_downloads/BSD release/FreeBSD-10.3-RELEASE-amd64-dvd1.iso
1434624 /media/ejs/huge390GB/home_old/mymac/Downloads/Fedora-Live-Workstation-x86_64-23-10.iso
2099200 /media/ejs/huge390GB/home_old/mymac/Downloads/Fedora-Server-DVD-x86_64-23.iso
2891700 /media/ejs/huge390GB/isos/gentooLinux.iso
270336  /media/ejs/huge390GB/isos/gparted-live-0.25.0-1-i686.iso
3198720 /media/ejs/huge390GB/isos/windows 10/Windows.iso
6208608 /media/ejs/huge390GB/isos/Windows 10 Final AIO (22 in 1) (32 Bit and 64 Bit) ISO + activator/Windows_10_AIO_22in1_x86_x64.iso
3198720 /media/ejs/huge390GB/isos/Windows.iso
1010688 /media/ejs/huge390GB/hadoop/ubuntu-14.04.1-desktop-i386.iso
700928  /media/ejs/huge390GB/ubuntu_souvenior/opt/utorrent-server-alpha-v3_3/archlinux-2016.01.01-dual.iso
13680   /media/ejs/huge390GB/ubuntu_souvenior/opt/utorrent-server-alpha-v3_3/kali-linux-2016.1-amd64/kali-linux-2016.1-amd64.iso
102400  /media/ejs/huge390GB/windowsbackup/SystemReserved_sda1.iso
122776576   /media/ejs/huge390GB/windowsbackup/Windows_sda2.iso
699520  /media/ejs/huge390GB/otherHDD/desk-things/archlinux-2016.01.01-dual.iso
6976    /media/ejs/huge390GB/otherHDD/sweeping/datamining/desk/mydesk/vai.iso
627872  /media/ejs/huge390GB/otherHDD/sweeping/prev_downloads/boot-repair-disk-64bit.iso
4963328 /media/ejs/huge390GB/otherHDD/sweeping/prev_downloads/Qubes-R3.1-rc2-x86_64.iso
300164  /media/ejs/myspace226/boxes/page5/play_xxe.iso
3092932 /media/ejs/myspace226/oldWinDesktop/new desktop/desk/windows 10/Windows.iso
5986044 /media/ejs/myspace226/WinDownload11.10.16/prev/Windows 10 Final AIO (22 in 1) (32 Bit and 64 Bit) ISO + activator/Windows_10_AIO_22in1_x86_x64.iso
1796    /media/ejs/41791947-27ae-4b0f-9dd4-2d3a2f442dea/usr/lib/memtest86+/memtest86+.iso
3004772 /media/ejs/41791947-27ae-4b0f-9dd4-2d3a2f442dea/opt/utorrent-server-alpha-v3_3/kali-linux-2016.2-amd64/kali-linux-2016.2-amd64.iso
102400  /media/ejs/BEAE4EDCAE4E8CB9/$RECYCLE.BIN/S-1-5-21-2418281319-387379063-377695367-1000/$R4KMAWS/SystemReserved_sda1.iso
70466560    /media/ejs/BEAE4EDCAE4E8CB9/backup/kali_backup.iso
102400  /media/ejs/BEAE4EDCAE4E8CB9/backup/windowsbackup/SystemReserved_sda1.iso
122776576   /media/ejs/BEAE4EDCAE4E8CB9/backup/windowsbackup/Windows_sda2.iso
237280  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/21LTR.com_Scene1_2.120_v1.0.iso
221184  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/axis2_and_tomcat_manager.iso
11512   /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/BadStore_123s.iso
191488  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/cve-2007-1860.iso
177152  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/cve-2008-1930.iso
176128  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/cve-2012-1823.iso
339968  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/cve-2012-2661.iso
168960  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/cve-2012-6081.iso
19584   /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/cve-2014-6271.iso
1752028 /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/DVL_1.5_Infectious_Disease.iso
491244  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/DVWA-1.0.7.iso
177152  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/ecb.iso
176128  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/from_sqli_to_shell.iso
177152  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/from_sqli_to_shell_II.iso
167936  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/from_sqli_to_shell_pg_edition.iso
416768  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/GameOver.0.1.null.iso
191488  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/linux_host_review.iso
446416  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/Loophole.iso
320512  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/rack_cookies_and_commands_injection.iso
179200  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/php_include_and_post_exploitation.iso
100480  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/play_session_injection.iso
179200  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/web_for_pentester.iso
361472  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/web_for_pentester_II.iso
193536  /media/ejs/BEAE4EDCAE4E8CB9/boxes/boxes/xss_and_mysql_file.iso
301376  /media/ejs/BEAE4EDCAE4E8CB9/boxes/page5/play_xxe.iso
1887432 /media/ejs/BEAE4EDCAE4E8CB9/data/iv videos/iv_videos.iso
6329536 /media/ejs/BEAE4EDCAE4E8CB9/GAMES/Bioshock Series/BIOSHOCK/BIOSHOCK.ISO
5384120 /media/ejs/BEAE4EDCAE4E8CB9/GAMES/Outlast.Whistleblower-RELOADED/rld-outwhistle.iso
4159488 /media/ejs/BEAE4EDCAE4E8CB9/GAMES/POP/Disc/Prince of Persia - Warrior Within.iso
516224  /media/ejs/BEAE4EDCAE4E8CB9/programming/tejas_folder/imp softwares/VedaBase2003.iso
3344512 /media/ejs/BEAE4EDCAE4E8CB9/programming/tejas_folder/os/Fedora 8 i386 DV.iso
993280  /media/ejs/BEAE4EDCAE4E8CB9/programming/tejas_folder/os/ubuntu-14.04-desktop-i386.iso
2099204 /media/ejs/home/mymac/Downloads/Fedora-Server-DVD-x86_64-23.iso
1434628 /media/ejs/home/mymac/Downloads/Fedora-Live-Workstation-x86_64-23-10.iso
1451060 /media/ejs/home/mymac/Downloads/ubuntu-16.04-desktop-amd64.iso
751640  /media/ejs/home/mymac/Downloads/archlinux-2016.05.01-dual.iso
848856  /media/ejs/home/mymac/MultiCD/FreeBSD-11.0-CURRENT-amd64-20160518-r300097-disc1.iso
1008    /media/ejs/home/mymac/MultiCD/multicd.iso
751620  /media/ejs/home/mymac/MultiCD/archlinux-2016.05.01-dual.iso
1220    /media/ejs/windows/Program Files (x86)/NeoSmart Technologies/EasyBCD/profiles/nst_mac.iso
544 /media/ejs/windows/Program Files (x86)/NeoSmart Technologies/EasyBCD/profiles/plop.iso
16  /root/doc.iso
25092   /opt/utorrent-server-alpha-v3_3/padding_oracle.iso
7872    /usr/share/u3-pwn/backup/origU3/U3 System.iso
4   /usr/share/doc/minicom/tables/mc.iso
57088   /usr/share/virtualbox/VBoxGuestAdditions.iso
504648  /home/ejs/Downloads/Project IGI.iso
    
por juggernauthk108 01.01.2017 / 18:10

2 respostas

2

Por que usar awk quando du pode fazer isso por você?

sudo find / -type f -iname *.iso -print0 | du -h --files0-from=- --total

du pode obter uma lista de arquivos de um arquivo (ou stdin se o arquivo for - ) e pode imprimir o total:

$ find . -type f -iname '*.iso' -print0 | du -h --files0-from=- --total
1006M   ./OS/ubuntu-14.04.3-desktop-amd64.iso
1.4G    ./OS/ubuntu-16.04-desktop-amd64.iso
1.5G    ./OS/ubuntu-16.10-desktop-amd64.iso
3.9G    total
    
por muru 01.01.2017 / 18:18
0

Eu sempre uso 'du -sh *' para encontrar a quantidade de espaço que várias árvores de diretório usam. Você poderia colocar os ISOs em uma pasta e executar esse comando, substituindo * pelo nome da pasta. Você pode integrar isso no seu script.

    
por Kyle H 01.01.2017 / 18:12