Posts Tagged ‘bash’
Posted on June 14, 2010 - by Sarath
diffdir : A utility to diff between directories
Hey,
I have been working on GSOC project on Pardus Live installer. I work on a separate svn branch for GSOC. When working across many files, we many need to generate diff between numerous files recursively working directory and some other branch directory. svn diff command helps only if the directories are fork of same svn repo and with change in revisions or so.
I needed a generic tool to make diff out of two directories. But googling a few minutes didn’t give me pleasing results and hence I am here with my own script.
Try out and comment.
#Filename: diffdir.sh
#Description: A utility to take diff of files recursively between two directories
#Author: Sarath Lakshman
#e-mail: sarathlakshman@slynux.com
#Homepage: http://www.sarathlakshman.com
olddir=$1
newdir=$2
if [ $# -ne 2 ];
then
echo -e "\nUsage: $0 [DIR OLD] [DIR NEW] > data.diff\n\n"
exit 0
fi
(cd $olddir; find . -type f ! -regex ".*\.svn.*" ) > /tmp/files.$$
(cd $newdir; find . -type f ! -regex ".*\.svn.*" ) >> /tmp/files.$$
sort /tmp/files.$$ -u -o /tmp/reqfiles.$$
cut -c3- /tmp/reqfiles.$$ > /tmp/uniqfiles.$$
for file in `cat /tmp/uniqfiles.$$`;
do
[ -e "$olddir/$file" ] && [ -e "$newdir/$file" ]
if [ $? -ne 0 ];
then
echo [NEW] $file\:
echo ===================================================================
[ -e "$olddir/$file" ] && cat "$olddir/$file"
[ -e "$newdir/$file" ] && cat "$newdir/$file"
else
diffed_data=`diff -u "$olddir/$file" "$newdir/$file"`
if [[ -n $diffed_data ]];
then
echo $file\:
echo ===================================================================
echo "$diffed_data"
echo
fi
fi
done
Download the script : diffdir.sh
UPDATE : diff -Naur olddir newdir will do the stuff
Posted on June 1, 2010 - by Sarath
InCTF hacking challenge, my team r00tkit @ second position
Recently I participated in India’s first Capture the Flag style hacking challenge, InCTF. 160 teams from all over India participated in the CTF contest. Each team consisted of at most 5 members.
The finals of the event was really fun. We had real reach machines on the network connected through a VPN. The scores are based on attacking other machines, defending, giving ethical advisories. Scores are based on Flags submission. Flags can be captured from vulnerable services on machines of other teams.
Each team is given a vulnerable virtual image of a GNU/Linux system with four services. We have to patch it to prevent others attacking and capturing flag from our host. We have to exploit other’s services and capture the flag.
The most exciting part of the game was that, we exploited a service called therasus and got a root shell.
We did rm -rf / on many machines of oponents and had fun watching their systems getting down
My team r00tkit had only two members, my friend Syamlal and I. It was the first time we were participating for a realtime CTF event.
We reached second position in the hacking challenge.
Good work Team BIOS, CTF organizers.
For more see, http://inctf.amrita.ac.in/
Posted on April 13, 2009 - by Sarath
Check data transfer / bandwidth
I found this interesting !
dd if=/dev/zero of=/dev/null bs=1M count=32768
It returns the data transfer rate.
slynux@slynux-laptop:~$ dd if=/dev/zero of=/dev/null bs=1M count=32768 32768+0 records in 32768+0 records out 34359738368 bytes (34 GB) copied, 3.72538 s, 9.2 GB/s
It says my laptop has data transfer rate = 9.2GBps

Solve real-world shell scripting problems with over 110 simple but incredibly effective recipes.

