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
#!/bin/sh | |
echo -n 'ア' | xxd -b | awk '{for(i=2;i<=NF-1;i++){print $i}}' | xargs | |
echo -n 'あ' | xxd -b | awk '{for(i=2;i<=NF-1;i++){print $i}}' | xargs | |
echo -n 'アイウエオ' | xxd -b -c 256 | awk '{for(i=2;i<=NF-1;i++){print $i}}' | xargs | |
echo -n 'アイウエオ' | tr 'ア' 'あ' | xxd -b -c 256 | awk '{for(i=2;i<=NF-1;i++){print $i}}' | xargs |
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
#!/bin/sh | |
cat shellgei | # 元AAの出力 | |
sed '/^ *$/d' | # 余分な行の除去 | |
awk -vFS= '{for(i=1;i<=NF;i++){str[i]=str[i]""$i}} END{for(i=1;i<=NF;i++){print str[i]}}' | # 行列転置 | |
grep -v '^ *$' | # 余分な列(この処理時点では行)の除去 | |
awk -vFS= '{for(i=1;i<=NF;i++){str[i]=str[i]""$i}} END{for(i=1;i<=NF;i++){print str[i]}}' # 行列転置 |
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
#!/bin/sh | |
cat triangle | # 元テキストの出力 | |
awk '{for(i=NF;i>=1;i--){st[NF-i]=$i" "st[NF-i]}} END{for(n in st){print st[n]}}' | # 右回転時の各段の出力 | |
awk '{for(i=1;i<NR;i++){printf " "}; print $0}' | # 幅合わせの処理 | |
tac # 上下の反転 |
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
#!/bin/sh | |
#Q4.1 | |
echo -1 4 5 2 42 421 44 311 -9 -11 | # 数列の出力 | |
tr ' ' '\n' | # 1レコード1フィールドに整形 | |
sort -n | # 数値順でソート | |
awk '{print $0,sub(/-/, "", $0),gsub(/[0-9]/, "", $0)}' | # 1:数値, 2:正負フラグ 3:数値長 を出力 | |
awk '{arr[$2,$3] = arr[$2,$3]" "$1} END{for(n in arr){print arr[n]}}' | # 2:正負フラグ,3:数値長 をキーとして、1:数値を集計 | |
sort -k 1,1n # カテゴリ順にソート |
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 contents.tex | # 元ファイルの出力 | |
grep -E '^\\(|sub|subsub)section{' | # section, subsection, subsubsectionレコードの抽出 | |
sed 's/\\label.*//' | # labelマクロの除去 | |
sed 's/}$//' | # *sectionマクロ終了文字の除去 | |
sed 's/{/<FS>/' | # *sectionマクロ開始文字をフィールドスペースに変換 | |
awk -F'<FS>' ' | |
/\\sec/{s++; ss=0; print s,$2} | |
/\\subsec/{ss++; sss=0; print s"."ss,$2} | |
/\\subsub/{sss++; print s"."ss"."sss, $2} | |
' # 出力の整形 |
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
#!/bin/sh | |
curl -s http://traininfo.jreast.co.jp/train_info/kanto.aspx | | |
nkf -Lu | | |
grep -A 1 'text-tit-xlarge' | | |
sed '/acess_i/s/.*alt="\([^"]*\)".*/\1/' | | |
sed 's/<[^>]*>//g' | | |
tr -d -- '- ' | | |
awk NF=NF | | |
xargs -n 2 |
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
#!/bin/sh | |
yes command | | |
head -n 25 | | |
xargs | | |
sh -x 2>&1 | | |
sed 's/^+ //' | | |
sed 's/command/*/g' |
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
#!/bin/sh | |
w3m -dump -cols 200 'https://ja.wikipedia.org/wiki/%E5%85%83%E5%8F%B7%E4%B8%80%E8%A6%A7_(%E6%97%A5%E6%9C%AC)' 2>/dev/null | | |
grep '[ :][0-9]\{1,2\}年[ ^]' | | |
grep -v '定められず' | | |
sed '$d' | | |
awk '$0=$1' | | |
tr -d ' ' | | |
grep -o . | | |
sort | |
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
#!/bin/sh | |
w3m -dump -cols 200 'https://ja.wikipedia.org/wiki/%E5%85%83%E5%8F%B7%E4%B8%80%E8%A6%A7_(%E6%97%A5%E6%9C%AC)' 2>/dev/null | | |
grep '[ :][0-9]\{1,2\}年[ ^]' | | |
grep -v '定められず' | | |
sed '$d' | | |
awk '$0=$1' |
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
#!/bin/sh | |
echo 万中久乾亀亨享仁保元勝化吉同和喜嘉国大天字安宝寛寿平康延建弘徳応感慶成承授政文斉昌明昭景暦正武永治泰白祚神祥禄禎福老至興衡観護貞銅長雉雲霊養 | | |
awk -vFS= 'BEGIN{OFS=","} NF=NF' | | |
sed 's/.*/echo {&}{&}/' | | |
bash |
NewerOlder