To Love One’s Craft: Fun with grep and RegEx…
Mar 27
How-To Ext, JavaScript No Comments
I just read an interesting post by Dave Nelson (spugbrap) in which he details all the fun he had writing a script to search through Ext JS source code and open it with Textpad.
So, I checked the TextPad help to see if I could pass in the name of a file containing full file paths for TextPad to open.
You just need to put an at sign (@) before the filename, and TextPad will look at that file to find a list of files to open. So, I decided to create a temporary file, output the filenames found and converted by my set of commands (above) into that temporary file, and then run TextPad, passing the temporary filename preceded by an @ sign.
textpad $(for g in 'for f in \'grep -Rli "new Ext.Panel" *\'; do (grep -Hn -m 1 "new Ext.Panel" $f | sed -e 's/\(^[^:]\+\):\([0-9]\+\):.*$/\1(\2/g'); done'; do echo 'cygpath -w -a ${g/\(*/}'\(${g/*\(/},'grep -m 1 "new Ext.Panel" ${g/(*/} | sed -e 's/\t/ /g' -e 's/new Ext.Panel.*$//g' | wc -c'\); done) &I’m sure this could be done more efficiently, but this was a fun challenge to take on, and I managed to find a way to do what I wanted to do.
Twitter
Delicious
RSS