19 Oct
2014
19 Oct
'14
2:31 p.m.
Nowaker <enwukaer@gmail.com> writes:
I would like these oneliners as long as they have sensible names, e.g. octal2hex instead of o2x.
For interactive use it would probably be the best to provide the functions in one file and source it in your shell. This way it is much easier to modify than all those files. This bash snippet should roughly do the same: #!/bin/bash declare -A base base[b]=2 base[o]=8 base[d]=10 base[h]=16 for i in "${!base[@]}" do for o in "${!base[@]}" do source <(echo \ "function ${i}2${o} { \ echo "obase=${base[$o]};ibase=${base[$i]}; \$@\" | bc; }"\ ) done done