Wednesday, July 25, 2007

Useful Unix Commands

#To find and Replace a string recursivly
find . -name \*.txt -type f -exec sed -i 's/Test1/Test2/g' {} \;

#To Uncompress a tar.gz file
gunzip -c filename.tar.gz tar xvf -

# To Search the file excluding the # [Comments ]mark in it
grep -c -v "^#" /opt/irisa/.fetch*rc?


#To Insert a New Line above a PATTERN Match:
sed '/connection-pool>/i\n' test
this will insert two lines on top of matched patter "/connection-pool>"