Saturday 29 October 2011

scanning web data with python

page = urlopen("http://www.whatever.org")

text = page.read().decode("utf8")
start = text.find('findThisText')

Friday 28 October 2011

mass file renaming

$ for i in *.old; do mv $i ${i/old/new}; done


or, from http://www.thegeekstuff.com/2010/07/bash-string-manipulation/
use  % to delete the shortest match from the back of the string, then append `.svg':

Rename all .pdf files to .svg:
====================

$ for i in `ls *.pdf`; do mv $i ${i%.pdf}.svg; done


The `ls` command is superfluous:

$ for i in *.pdf; do mv $i ${i%.pdf}.svg; done


Neat!