Replacing a piece of XML with awk

This script searches for an initial tag and and closing one and replaces the content.

# !/bin/bash
awk ‘
BEGIN {pr = 1;one = 0}
/<Name>OPENING<\/Name>/ {pr = 0;}
{ if (pr) print }
{ if (!pr && !one) {print (“\t\t <Name>OPENING</Name> \n \t\t\t <Value>false</Value> \n \t\t<Type>STOPHERE</Type> \n ” ); one =1 ;}}
/<Type>STOPHERE<\/Type>/ {pr = 1;}
‘< $1

Not the most elegant solution but lends itself to multiple replacements.

 

find . | grep file.xml | xargs -I {J} -n 1 bash -c ‘ ./aw.sh {J} > {J}.new ; mv -f {J}.new {J}  ‘

nJoy 😉

 

 

 

Track ftp password from tcpdump Linux

Very nice and simple:

tcpdump port ftp -l -A | egrep -i ‘pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user ‘ –color=auto –line-buffered -B20

nJoy  😉

Adding all new files and subdirs to svn

Sometimes you find yourself catching up with some devs who did not care to add all the stuff they should to SVN or you want to make sure all files are in SVN. Well here’s a hand script :

svn status | awk ‘{if ($1 == “?”) print $2 }’ | xargs svn add

nJoy 😉