![날짜 범위를 사용하여 1GB 이상의 파일을 필터링하는 방법](https://linux55.com/image/113569/%EB%82%A0%EC%A7%9C%20%EB%B2%94%EC%9C%84%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%201GB%20%EC%9D%B4%EC%83%81%EC%9D%98%20%ED%8C%8C%EC%9D%BC%EC%9D%84%20%ED%95%84%ED%84%B0%EB%A7%81%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
누구든지 크기가 1GB를 초과하고 날짜 범위가 5월 1일부터 5월 31일까지인 파일을 찾는 스크립트나 명령을 제안할 수 있습니까?
스크립트나 명령을 만드는 데 도움을 주세요. 5월 1일부터 5월 31일까지의 기간 중 크기가 1GB를 초과하는 모든 파일을 이동하고 싶습니다.
감사합니다, 비스와짓
답변1
이것이 당신에게 효과가 있습니까?
touch --date "2017-05-01" /tmp/start
touch --date "2017-05-31" /tmp/end
find /path/ -type f -newer /tmp/start -not -newer /tmp/end -size +1G -exec mv "{}" /path/to/new/dir/ \;
이를 bash 스크립트(예 scriptname.sh /path/to/search/dir /path/to/destination/dir
: )로 사용할 수 있습니다.
#!/usr/bin/env bash
touch --date "2017-05-01" /tmp/start
touch --date "2017-05-31" /tmp/end
find "$1" -type f -newer /tmp/start -not -newer /tmp/end -size +1G -exec mv "{}" "$2" \;
rm /tmp/start /tmp/end