Last active
August 29, 2015 14:08
-
-
Save stefan-mees/1d13fb0e5e97776ea46d to your computer and use it in GitHub Desktop.
awk magic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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