Monday, March 1, 2010

case insensitisation in shell case statements

My hand got sore (ahem) typing [Yy][Ee][Ss] for the millionth time.


perl -pe 's/([a-zA-Z])/sprintf("[%s%s]",uc($1),lc($1));/eg if /^\s*\S+\)/;'


I tried to be cute and do it in sed, but I realised perl was probably the quickest way of getting what I want due to s///'s e flag.

No comments: