A script fo finding orphan files
Edd Budulea
e_timotei at yahoo.com
Tue Oct 10 09:39:17 UTC 2006
Hi, I like to keep my computer clean and inevitable
after some time I'll end up with files (apps) that
don't belong to any module. After 2 manual attempts of
finding these files I've ended up with this script
that maybe some others will find it useful.
It will make a list of all files that are belonging to
modules, then it will find all files that are on hdd
in applications' root directory (it will filter out
/home /tmp /mnt and others that are not a target of
any lunar module) and make a diff in order to make a
file with all the files that are not in a module.
======= cut here =======
#!/bin/sh
if [[ "" == "$1" ]] ; then
echo -e "Usage\n\t$0 {Output file}"
exit 1
fi
INSTMOD=`mktemp`
: > $INSTMOD
echo Gathering the files that are installed by
lunar...
LIMIT=`lvu installed | wc -l`
CURSOR=0
for nene in `lvu installed | sed -e "s/:.*//"` ; do
lvu install $nene >> $INSTMOD
((VAL=$CURSOR / $LIMIT))
echo -ne "\r$VAL%"
((CURSOR=$CURSOR + 100))
done
NOTOR=`mktemp`
sort -u $INSTMOD > $NOTOR
echo -e "\r100%.DONE..."
echo Gathering the files that are in app\'s root
directories...
: > $INSTMOD
for nene in `sed -e "s#\(/[^/]*\).*#\1#" $NOTOR | sort
-u` ; do
echo Processing "$nene" ...
find "$nene" -type f >> $INSTMOD
done
EXIST=`mktemp`
sort -u $INSTMOD > $EXIST
echo "DONE..."
echo "Making differences"
diff $NOTOR $EXIST --new-line-format="%L"
--old-line-format="" --unchanged-line-format="" | grep
-vE
"^((/usr/src/)|(/var/(log|cache|spool)/)|(/var/.*/lunar/))"
> "$1"
#mv $NOTOR "$1".notor
#mv $EXIST "$1".exist
rm -f $NOTOR
rm -f $EXIST
rm -f $INSTMOD
=======cut here=======
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Lunar
mailing list