Created
June 18, 2015 19:55
-
-
Save mikkun/5677af24e466d6c27648 to your computer and use it in GitHub Desktop.
「第17回ジュンク堂はシェル芸が乗っ取った勉強会」解答例
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
2015/06/18「第17回ジュンク堂はシェル芸が乗っ取った勉強会」の解答例 | |
問題URL: http://blog.ueda.asia/?p=6454 | |
A1-1: | |
cat data1 | sort -k1,1 | awk 'BEGIN{ORS=""}{print $1!=prev?"\n"$1" "$2:" "$2;prev=$1}' | awk 'NR!=1' | |
A1-2: | |
cat data1 | sort -k1,1 | awk 'BEGIN{ORS=""}{print $1!=prev?"],"$1":["$2:","$2;prev=$1}END{print "]}\n"}' | sed 's/^],/{/' | |
A2: | |
cat -n data2 | sort -k2,3n | uniq -Df1 | |
A3: | |
cat data3 | sed 's/],"/\n/' | tr -cd 'a-z0-9:,\n' | sed 's/:\|,/ /g' | awk '{sum=0;for(i=2;i<=NF;i++)sum+=$i;print $1":"sum}' | |
A4-1: | |
echo 2001:db8::9abc | awk 'BEGIN{FS=":";OFS=":"}{while(NF<8){sub(/::/,"::0:")};for(i=1;i<=8;i++)$i=$i==""?0:$i;print}' | |
A4-2: | |
echo ::1 | awk 'BEGIN{FS=":";OFS=":"}{while(NF<8){sub(/::/,"::0:")};for(i=1;i<=8;i++)$i=$i==""?0:$i;print}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment