Created
April 10, 2014 13:19
-
-
Save laughk/10381390 to your computer and use it in GitHub Desktop.
第10回記念シェル芸勉強会@シェルリアンタワー 実行ワンライナーまとめ
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
## 普通に | |
echo 2 5 9 8 1 3 7 4 | sed 's/ /+/g' | bc | |
## 変態だと思ったがそうでもなかった | |
echo 2 5 9 8 1 3 7 4 | tr ' ' '\n' | awk '{sum = sum + $0} END{print sum}' |
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
## awk使わないで無理したらわけわからなくなったがなんかできた。 | |
cat toi2 | | |
grep -o '\w' | | |
while read num ; do | |
sum=`expr $sum + $num` | |
echo $sum | |
done | | |
tail -n1 |
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
function show_text(){ | |
cat << EOF | |
筆者は朝、目玉焼きを食べた。 | |
昼、著者は卵がけごはんを食べた。 | |
そして夜、著者はマンハッタンの夜景を | |
見ながらゆで玉子を食べた。 | |
EOF | |
} | |
## 開業挟んで行数カウント | |
show_text | tr -d '\n' | sed 's/./&\n/g' | wc -l | |
## wcのオプションで | |
show_text | tr -d '\n' | wc -m |
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
echo aabbcdabbcccdd | sed 's/./&\n/g' | sort | uniq -c | awk '{if($1==3){print $NF}}' |
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
mv `find -type f` . |
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
## grep のリターンコードを利用して | |
( | |
find -type f | | |
while read f ; do | |
grep hoge $f && mv $f a/ | |
grep huga $f && mv $f b/ | |
done | |
) >/dev/null 2>&1 | |
## ファイル名と文言を1行にまとめて出して、そこからawkでシェルスクリプトを生成し実行 | |
grep . file* | | |
awk -F: ' | |
/hoge/ {print "mv", $NF" a/"} | |
! /hoge/ {print "mv", $NF" b/"} | |
' | | |
sh |
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
echo 'タイムアップ\(^o^)/' |
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
## カッとなってやった | |
while : ; do | |
python -c 'import random; print(random.randint(0,999999))' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment