Created
December 15, 2010 22:46
-
-
Save mrdaemon/742734 to your computer and use it in GitHub Desktop.
Copy corrupt/missing files from windows sfc log from known good windows 7 install mounted at /media/wsystem. Thank you sfc for creating logs that are impossible to parse without sed grep and awk magic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -i -e "could not" -e "cannot" sfclog.txt | \ | |
awk -F ';' '{ print $1; }' | awk -F "??" '{ print $3; }' | \ | |
sed -e 's/^\\//' -e 's/"\\\[.*\]"/\\/g' -e 's/"$//' | sort | uniq | \ | |
tee -a ./win7sysfiles/FILELIST.TXT | \ | |
sed -e '/^$/d' -e 's/\\/\//g' -e 's/^C:\(.*\)$/\/media\/wsystem\1/' \ | |
-e 's/\([ ()]\)/\\\1/g' | \ | |
while read i ; do if [ -f "$i" ] ; then STATUS="ERROR" ; \ | |
cp "$i" ./win7sysfiles/ && STATUS="COPIED" ; else STATUS="MISSING" ; fi ; \ | |
printf "%-30s%-30s\n" "`basename \"$i\"`" "[$STATUS]" ; done \ | |
&& echo -n "Creating checkums..." ; for f in ./win7sysfiles/* ; do \ | |
md5sum $f > $f.md5sum ; done ; echo "done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I originally wrote this crap on a single line. I added lovely linebreaks to make it semi-readable. I'm sorry.