こんなことがしたい。
echo "aiueo700" | sed 's/\([a-z]*\)\([0-9]*\)/\1 and \2/g'
# => aiueo and 700
| #!/usr/bin/ruby | |
| # 15で割った余りに注目してFizzBuzz | |
| class Integer | |
| def fizzbuzz | |
| case self % 15 | |
| when 0 then "FizzBuzz" | |
| when 5,10 then "Buzz" | |
| when 3,6,9,12 then "Fizz" | |
| else self |
| mkdir im | |
| for i in {01..51}; do | |
| seq 1 $i | awk '{r = 8*atan2(1,1)/50 * $1; printf "%f,%f ", 200*cos(r) + 250, 200*sin(r) + 250}' | xargs -I@ convert -size 500x500 xc:Yellow -fill Red -stroke Black -draw 'path "M 250,250 @ z"' im/$i.png | |
| done | |
| convert im/*.png -delay 10 circle_graph.gif | |
| rm -r im |
| seq 1 230 | awk '{r = 8*atan2(1,1)/47 * $1; printf "%f,%f ", sin($1)*$1*cos(r) + 250, sin($1)*$1*sin(r) + 250}' | xargs -I@ convert -size 500x500 xc:yellow -fill red -stroke Black -draw 'path "M @ z"' a_flower.png |
eval echo "fbfbfbf" "| sed 's/f/faffbffbfbfafaffbfbfafaffaffbf/g'"{,} | grep -o [ab]*f | awk 'BEGIN{x=250;y=250;rx=0;ry=13} {tmp=rx; printf "%s,%s ", x,y; x=x+rx; y=y+ry; if($1=="af"){rx=-ry; ry=tmp}else if($1=="bf"){rx=ry; ry=-tmp}} END{printf "%s,%s", x,y}' | xargs -I@ convert -size 1000x1000 xc:DarkRed -fill none -stroke Yellow -strokewidth 4 -draw "path 'M @'" koch_island.png
eval echo "fbfbfbf" "| sed 's/f/ffbfbfbfbfbfaf/g'"{,,} | grep -o [ab]*f | awk 'BEGIN{x=50;y=550;rx=0;ry=20} {tmp=rx; printf "%s,%s ", x,y; x=x+rx; y=y+ry; if($1=="af"){rx=-ry; ry=tmp}else if($1=="bf"){rx=ry; ry=-tmp}} END{printf "%s,%s", x,y}' | xargs -I@ convert -size 1000x1000 xc:DarkRed -fill none -stroke Yellow -strokewidth 4 -draw "path 'M @'" flower.png| # National Anthem of USSR | |
| # Execute this ShellScript, Soviet Anthem Plays You. | |
| # Before execute this, you have to install Sox(Sound eXchange) by apt-get / brew. | |
| mkdir notes | |
| cat << EOS | grep -v "-" | awk '{if ($1=="z") {print "sox -n -c 2 notes/"NR".wav trim 0.0", $2/4} else {{print "sox -n -c 2 notes/" NR ".wav synth", $2/4, "pluck", $1, "\\"} if ($3!="") {print "pluck", $3, "\\"} if ($5!="") {print "pluck", $5, "\\"} print ";"}}END{print "sox notes/{1.."NR-1"}.wav song_new.wav"}' | bash | |
| E4 4 G4 4 C5 4 | |
| - | |
| D4 1 G4 1 D5 1 | |
| C4 1 G4 1 C5 1 |
| #!/bin/bash | |
| convert -size 1500x500 pattern:checkerboard -fill Black -pointsize 400 -font "Symbola" -draw 'text 30,350 "Sh ell 💩"' -write mpr:L -crop 500x500+0+0! -virtual-pixel none -distort Perspective '0,0 100,350 500,0 100,150 0,500 250,400' -write mpr:tmp +delete mpr:L -crop 500x500+500+0! -virtual-pixel none -distort Perspective '0,0 100,150 500,0 250,100 0,500 250,200' mpr:tmp -composite -write mpr:tmp +delete mpr:L -crop 500x500+1000+0! -virtual-pixel none -distort Perspective '0,0 250,200 500,0 400,150 0,500 250,400' mpr:tmp -composite unko.png |
| #!/bin/bash | |
| # Usage | |
| # 先頭のecho ""にパスカルの三角形の何段目まで二項係数を計算したいか入力します。 | |
| # 8行目行中にある「{print $0}」の部分を削除すれば、パスカルの三角形は表示せずに求めたい段の二項係数のみが表示されるようになります。 | |
| # Copyright 2019 YUUKIToriyama All Rights Reserved | |
| echo "10" | awk '{for (n=1; n<=$1; n++){ for (m=1; m<=n; m++){printf "$"m"+$"m+1","} printf "\n" }}' \ | |
| | awk 'BEGIN{printf "echo 1 1"}{printf " | awk \047{print $0}END{print 1," $0 "1}\047"}' \ | |
| | bash |
完全にエクセル函数を頭に入れた人用の「セルの入力からグラフの作成まですべてをコマンド入力だけで済ませるプラグイン」みたいなのをつくろうかと思っている。