Skip to content

Instantly share code, notes, and snippets.

@greymd
Last active June 4, 2017 01:03
Show Gist options
  • Save greymd/885097d96cbb82e8e2cfdbd90ab0bfea to your computer and use it in GitHub Desktop.
Save greymd/885097d96cbb82e8e2cfdbd90ab0bfea to your computer and use it in GitHub Desktop.
山田エルフ.sh
yes 山田エルフ \
| head -n 5 \
| awk -vFS= -vOFS=" " 'NR==1{system("echo "$0"|rev|tr -d \\\\n");print $2$3$4$5};NR<6{s=$(NR+1);for(i=0;i<4-NR;i++)printf OFS;printf s;for(i=1;i<NR;i++)printf OFS;printf s;for(i=1;i<NR;i++)printf OFS;print s;}'
# -- Result
# フルエ田山田エルフ
#    田田田
#   エ エ エ
#  ル  ル  ル
# フ   フ   フ
# もっと短く。
export P='for(i=1;i<NR;i++)printf OFS;printf s;'; yes 山田エルフ \
|head -n 5 \
| awk -vFS= -vOFS=  " 'NR==1{system("echo "$0"|rev|tr -d \\\\n");print $2$3$4$5}{s=$(NR+1);'"${P/NR/5-NR}$P${P/printf s/print s}"'}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment