![특정 파일 크기까지 디렉터리에서 발견된 파일의 합계를 나열하는 좋은 방법은 무엇입니까?](https://linux55.com/image/154056/%ED%8A%B9%EC%A0%95%20%ED%8C%8C%EC%9D%BC%20%ED%81%AC%EA%B8%B0%EA%B9%8C%EC%A7%80%20%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EC%97%90%EC%84%9C%20%EB%B0%9C%EA%B2%AC%EB%90%9C%20%ED%8C%8C%EC%9D%BC%EC%9D%98%20%ED%95%A9%EA%B3%84%EB%A5%BC%20%EB%82%98%EC%97%B4%ED%95%98%EB%8A%94%20%EC%A2%8B%EC%9D%80%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
이 목록은 쉽게 이동할 수 있도록 타르 볼을 만드는 데 사용됩니다. 지금까지 제가 생각해낸 내용은 다음과 같습니다. 10GB보다 큰 파일을 파일에 추가합니다.
find . -type f -exec ls -al {} + | awk '{ total += $5 }; {print $9}; {if (total > 10000000000) {print total; total = 0 }}; END { print total }' > /tmp/testfile.txt
각 타르 볼에 고유한 이름을 지정하고 싶지만 모든 결과를 /tmp/testfile.txt에 저장합니다.
이것을 시도했지만 약간 번거로운 것 같습니다.
find . -type f -exec ls -al {} + | awk '{ filenumber };{ total += $5 }; {print $9}; {if (total > 10000000000) {print total; total = 0; filenumber++;print "This is filenumber"filenumber".tar" }}; END { print total }' > /tmp/testfile.txt
이것이 내가 생각해낸 것입니다 -
find ./ -type f -exec ls -al {} + | awk 'BEGIN { filenumber };{ total += $5 }; {print $9 > "filename"filenumber".txt"}; {if (total > 10000000000) {print total; total = 0; filenumber++;print "This is filename"filenumber".txt" }}; END { print total }' > filecheck.txt
해당 명령 후에 결과를 명령에 제공합니다.
for file in $( find . -name "filename*.txt" -type f );do tar -cvf "$file.tar" -T "$file"; done