# Use the file names, not the relative path to them, as we grep like that ./PRE_DU
PRE_DU=sizes_before.du
POST_DU=sizes_after.du
diff_sizes() { du -ab | grep -Pv "^0\t" | grep -Pv "[0-9]+\t./(${PRE_DU})|(${POST_DU})" >${PRE_DU}; $1; du -ab | grep -Pv "^0\t" | grep -Pv "[0-9]+\t./(${PRE_DU})|(${POST_DU})+" >${POST_DU}; diff ${PRE_DU} ${POST_DU}; };
第一个场景 - 只有大小
添加以下脚本,
.bashrc
然后像这样使用它diff_sizes script.sh
第二个场景 - 大小和日期
添加以下脚本,
.bashrc
然后像这样使用它diff_sizes_and_dates script.sh
进一步的命令分解在这里