• Home
  • About
  • Archives
  • Book
  • Contact me
  • Photos
  • Projects
  • Talks
Subscribe: Posts | Comments | E-mail
  • ArticlesArticles which I authored
  • GSOCGoogle Summer of code archives
  • HacksExperiments
  • LifeIn and around life
  • Open SourceFree and Open Source Software
  • PardusContributions with Pardus Project

Sarath Lakshman

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.

#!/bin/bash
#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 :D

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 :)



  • About

    Sarath Lakshman is a Hactivist of Free and Open Source Software from Kerala.
    Read more about him.
  • My Book

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



  • Follow

  • Random Photos

    Arun Raghavan - Optimising applications
Hackfest @ MEC
  • Tweets

    • Preparing for your first-job interviews:
      http://t.co/SBdRl4At
      2011/11/30 23:31
    • is down. Having some issues with hosting account. I will update when it is back.
      http://t.co/Hj3u1qm1
      2011/11/29 11:59
    • Blog post: Preparing for your first-job interviews:
      http://t.co/SBdRl4At
      2011/11/29 09:47
    • Packt Publishers interviewed me.
      http://t.co/CMrvOPh
      2011/09/08 00:21
  • Calendar

    May 2012
    M T W T F S S
    « Nov    
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  
  • Archives

  • Blogroll

    • FOSS.IN
    • GNU Vision Blog
    • Hiran Effects
    • J5′s blog
    • Pardus planet
    • Praveen Arimbrathodiyil’s blog
    • Santhosh Thottingal
    • SLYNUX GNU Operating System
    • St Josephs HSS, Thalassery – Alumni
    • Swaroop CH
    • TT’s Jottings-Blog of VU2SWX
  • Tags

    algorithm automation bangalore bash bash scripting bug code college contribution define development facebook fedora foss fossmeet freedom free sms freesoftware Friends fun gnome gnu google google summer of code hack hacking hacks internet interview joy kde 4.1.2 kochi Life linux mec microsoft new year night nitc pardus pitivi python script summer of code video editor
Copyright © 2005 - 2010 Sarath Lakshman
Powered by Wordpress 3.04