Home

Geeklog: What I Learnt Today / Adam

Clearing up code inserted after hack

> Found some odd bits of code in an old website recently and thought I'd note down how I went about finding the additions. This one was fairly simple once you found the first file affected as they turned out that all the files were modified at the same date.
Finding files modified between two dates
find /messedup/ -newermt "2020-01-19" ! -newermt 2020-01-21 -ls

Finding modified files in two directories when you know that you have a good copy
diff -br --exclude=".DS_Store" /messedup/ /good/copy/folder/ >
difference.diff
gives you a diff file and its child folders with all the differences ignoring whitespace changes
if you just want the names of the files that don't match or where files only exist in directory or another. Ignoring OS X's .DS_store files.
diff -qbr --exclude=".DS_Store" /messedup/ /good/copy/folder/ >
difference-files.diff

Find files in a directory that aren't pictures where everything should be a picture e.g. badfile.php
find /messedup/images/ -type f -not -name "*.jpg" -not -name
"*.jpeg"  -not -name "*.JPG" -not -name "*.gif" -not -name "*.GIF" -not
-name "*.png"

/ Adam