free hit counter

Thursday, December 08, 2011

awk magic for git add

I'm a huge believer in carefully grouping files for commits.  This was altogether intuitive back in my TortoiseSVN days, but with command line git I'm finding awk is useful and more fun.

This command finds all the modified CMakelists.txt files and adds just them:

git status -s | egrep '^ M' | awk '/.txt/ {print $2}' | xargs git add

There's probably a less verbose way to make it happen, but I was surprised how little time it took to construct this command.

Monday, December 05, 2011

rename command: who knew?

I was trying to rename a whole bunch of files in a dir from on prefix to another.

Fiddling with xargs, when google lead me to rename. And it takes straight perl subtitution experssions! Tada:

rename 's/Android(.*)/UInput$1/' *