Wednesday, April 7, 2010

change html width attribute in table of a files using find grep and sed

in all files in a directory (php, html, etc), I wanted to change table's width, only if it was in a certain range

using ubuntu hardy heron, this is what i pulled out:


find . -maxdepth 1 -type f | xargs -I f egrep '<table .*(?>)?[^>]*>' f --color -H | grep width | grep -v % | sed -r "s/width\s*=\s*((\"|'))((59|6|7)[0123456789][0123456789])\1/width=\"100%\"/g" | sed -r "s/^([^:]*):.*/\1/g" | xargs -I f sed -i -r "s/width\s*=\s*((\"|'))((59|6|7)[0123456789][0123456789])\1/width=\"100%\"/g" f
somebody ?

No comments:

Post a Comment