31 lines
869 B
Fish
Executable file
31 lines
869 B
Fish
Executable file
#!/usr/bin/fish
|
|
|
|
cat $argv[1] \
|
|
# there's definitely a more elegant way to do this,
|
|
# but maybe not with sed, and probably not readably
|
|
| sed -E 's/oneight/18/g;
|
|
s/twone/21/g;
|
|
s/threeight/38/g;
|
|
s/fiveight/58/g;
|
|
s/sevenine/79/g;
|
|
s/eightwo/82/g;
|
|
s/eighthree/83/g;
|
|
s/nineight/98/g;
|
|
s/zerone/01/g;
|
|
s/one/1/g;
|
|
s/two/2/g;
|
|
s/three/3/g;
|
|
s/four/4/g;
|
|
s/five/5/g;
|
|
s/six/6/g;
|
|
s/seven/7/g;
|
|
s/eight/8/g;
|
|
s/nine/9/g;
|
|
s/zero/0/g;
|
|
s/[a-zA-Z]//g;
|
|
s/([0-9]{1})[0-9]*([0-9]{1})/\1\2/g
|
|
s/^([0-9]{1})$/\1\1/g' \
|
|
| tr '\n' '+' \
|
|
| sed 's/+$/\n/g;
|
|
s/^+//g' \
|
|
| bc
|