D0681.test-history-sed.sh (558B)
1 #!/bin/bash 2 3 # D0681 4 # 5 # "HISTTIMEFORMAT=__ble_ext__ history" 6 # の出力を整形する sed スクリプトのテスト 7 8 { 9 echo 1234 10 echo hello 11 echo world 12 echo '1234 ??aaaaa' 13 echo '111 ??echo test' 14 echo hello 15 echo world 16 echo '1 ??echo www' 17 echo '2 ??echo test' 18 echo '3 ??echo aaaa' 19 } | sed ' 20 s/^ *[0-9]\{1,\}\*\{0,1\} \{1,\}__ble_ext__)// 21 s/^ *[0-9]\{1,\}\*\{0,1\} \{1,\}??// 22 tF 23 ${H;s/.*//;bF;} 24 H;d 25 :F 26 x;s/^\n// 27 /\n/ { 28 s/['\''\\]/&/g 29 s/\n/\\n/g 30 s/.*/eval -- $'\''&'\''/ 31 } 32 p;s/.*// 33 ${x;/./{x;bF;};x} 34 d 35 '