Thursday, January 21, 2010

Customised search in Linux using find

Below is a code to customise search in Linux using find. find would recurse through all the directories. I needed to omit some directories which I knew didn't have the file I was looking for but instead have games. So recursing through them would cause enormous processor overhead and time loss. So I wrote a code in shell script to omit specific directories..

cd /
for aa in `ls`
do

if [ "$aa" != "resident_evil" ] ; then
if [ "$aa" != "usr1" ] ; then
if [ "$aa" != "usr2" ] ; then
if [ "$aa" != "usr3" ] ; then
if [ "$aa" != "unreal" ] ; then
if [ "$aa" != "quake3" ] ; then
echo -e " Current search path: "
cd $aa
pwd
find . -name "*.a"
fi
fi
fi
fi
fi
fi


cd /

done

No comments:

Print chess board in command line

The following bash one-liner will print a chess board in a terminal (the script works for the shells bash and ksh only) for (( i = 1; i ...