![sed를 사용하여 rsync 출력 필터링 --itemize-changes -i [중복]](https://linux55.com/image/229997/sed%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20rsync%20%EC%B6%9C%EB%A0%A5%20%ED%95%84%ED%84%B0%EB%A7%81%20--itemize-changes%20-i%20%5B%EC%A4%91%EB%B3%B5%5D.png)
rsync --itemize-changes -i --recursive --checksum --dry-run
두 드라이브의 내용을 비교한 후 다음 결과를 얻었습니다.
2024/03/12 08:31:01 [15248] .d Backups/Phone/Pictures/Screenshots/
2024/03/12 08:31:01 [15248] .f Backups/Phone/Pictures/Screenshots/Screenshot_20190726-175033.png
2024/03/12 08:15:12 [15248] cd+++++++++ Backups/User profile/user/.mozilla/firefox/fk3vbf2j.Old profile/storage/default/https+++www.example.org/ls/
2024/03/12 08:15:12 [15248] cf+++++++++ Backups/User profile/user/.mozilla/firefox/fk3vbf2j.Old profile/storage/default/https+++www.example.org/ls/index.html
파일 편집기에 비해 파일이 너무 크기 때문에 sed를 사용하여 수정되지 않은 파일과 폴더( 및 가 있는 파일 .d
) 를 필터링하고 싶습니다 ..f
답변1
sed '/[0-9\/]* [0-9:]* [[0-9]*] \.[fd]*[[:space:]]*.*/d' source_file > result_file
결과:
2024/03/12 08:15:12 [15248] cd+++++++++ Backups/User profile/user/.mozilla/firefox/fk3vbf2j.Old profile/storage/default/https+++www.example.org/ls/
2024/03/12 08:15:12 [15248] cf+++++++++ Backups/User profile/user/.mozilla/firefox/fk3vbf2j.Old profile/storage/default/https+++www.example.org/ls/index.html
이러한 이유로 나는 정규식을 성공적으로 만들었습니다.