!["du" 출력에 일반 파일만 포함하도록 하려면 어떻게 해야 합니까?](https://linux55.com/image/191156/%22du%22%20%EC%B6%9C%EB%A0%A5%EC%97%90%20%EC%9D%BC%EB%B0%98%20%ED%8C%8C%EC%9D%BC%EB%A7%8C%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8F%84%EB%A1%9D%20%ED%95%98%EB%A0%A4%EB%A9%B4%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%ED%95%B4%EC%95%BC%20%ED%95%A9%EB%8B%88%EA%B9%8C%3F.png)
디스크 사용량을 기준으로 모든 파일을 내림차순으로 나열하고 싶습니다.이것:
현재 디렉터리에서 가장 큰 파일 상위 10개를 나열합니다.
du . | sort -nr | head -n10
현재 디렉토리에서 가장 큰 디렉토리를 나열하려면 다음을 수행하십시오.
du -s * | sort -nr | head -n10
그러나 모두 디렉토리만 나열합니다.
du
출력에 일반 파일만 포함하려면 어떻게 해야 합니까 ?
보너스:
다음 du
옵션(효과가 없는 것으로 보임)의 목적은 무엇입니까? :
-a, --all write counts for all files, not just directories
답변1
GNU가 있는 경우 du
일반 파일(또는 디렉토리 또는 필터링하려는 모든 항목) 목록을 보내려면(또는 zsh에서 인수로 쉘 glob을 사용):find
find . -type f -print0 | du --files0-from=-
du *(.) # zsh, regular non-hidden files in the current directory
du
기본적으로 디렉터리 내의 파일 크기 합계만 인쇄되지만 다음과 같이 개별 파일 크기를 인쇄하도록 할 수도 있습니다 -a
.
% du /usr/bin
68 /usr/bin/lou_maketable.d
100 /usr/bin/vendor_perl
464 /usr/bin/core_perl
4 /usr/bin/site_perl
1104024 /usr/bin
% du /usr/bin -a | head
4 /usr/bin/preparetips5
36 /usr/bin/autoupdate
4 /usr/bin/python3.9-config
0 /usr/bin/mkoctfile
60 /usr/bin/zdump
16 /usr/bin/fstopgm
4 /usr/bin/brltty-setcaps
40 /usr/bin/sleep
8 /usr/bin/pnmquantall
20 /usr/bin/extract_mpeg2