Skip to content

Instantly share code, notes, and snippets.

@stefan-mees
Last active August 29, 2015 14:08
Show Gist options
  • Save stefan-mees/1d13fb0e5e97776ea46d to your computer and use it in GitHub Desktop.
Save stefan-mees/1d13fb0e5e97776ea46d to your computer and use it in GitHub Desktop.
awk magic
(for i in `find ./ -type f`; do export version=`head -c 100 $i | strings | awk '/^4\.[0-9]+/'`; echo "$i:$version"; done;) > /tmp/cache_versions.txt
cat nginx.conf | awk '{sub(/^[ \t]+/,"");a=0} /\{/{l++;a=1} /\}/{l--} {id="";for(i=a;i<l;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}'
for i in `find ./ -type f | xargs grep -sl '#if'`; do awk 'BEGIN {p = 1; n = 0} { if(n == 1) {n=0; p=1} if($1 ~ /(#if)/){ p = 0 }; if($1 ~/(#endif)/) {n = 1}; if(p == 1) {print } }' $i > $i.b; mv $i.b $i; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment