0

Given a directory with a tree of directories and files inside of it, presumably containing log files.

How to know which files got changed after running a specific application.

Taking into consideration that the modification time sometimes is of interest and sometimes not, so we need to handle both cases when

  • Only the logical size is checked and modification time is ignored
  • Both the logical size and the modification time are taken into consideration

1 Answer 1

0

First Scenario - Only Size

Add the following script to .bashrc then use it like that diff_sizes script.sh

# 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}; };

Second Scenario - Both Size and Date

Add the following script to .bashrc then use it like that diff_sizes_and_dates script.sh

alias file_sizes_and_dates="find . -type f -exec ls -al {} + | awk {'printf(\"%8s\t%s %2s %5s %s\n\",\$5,\$6,\$7,\$8,\$9)'}"

PRE_DU=sizes_before.du
POST_DU=sizes_after.du

diff_sizes_and_dates() { file_sizes_and_dates | grep -Pv "^\s*0\t" | grep -Pv " ./(${PRE_DU})|(${POST_DU})$" >${PRE_DU}; $1; file_sizes_and_dates | grep -Pv "^\s*0\t" | grep -Pv " ./(${PRE_DU})|(${POST_DU})$" >${POST_DU}; diff ${PRE_DU} ${POST_DU}; };

Further command breakdown is here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .