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
由于这些原因,我成功地制作了正则表达式: