查找 FS 上 ISO 占用的总空间?

查找 FS 上 ISO 占用的总空间?

我想要一个 awk 脚本来查找$1输出的总和

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

尽管以人类可读的格式输出并不困难,但如果可以即时完成则更好。

输出如下所示:

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

答案1

awk为何要使用du可以为您完成的事情?

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

du可以从文件(如果文件为 则从 stdin )中获取文件列表-,并且可以打印总数:

$ 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

答案2

我总是使用“du -sh *”来查找各种目录树使用的空间量。您可以将 ISO 放入文件夹中并运行该命令,将 * 替换为文件夹名称。您可以将其集成到脚本中。

相关内容