I am trying to create a bash alias or function which can pipe text to the stdin of the unix command bc.
I first attempted:
alias semitone="echo \"scale=10; e(l(2.))\" | bc"
Which bash parses ok, but it fails with a bc runtime error:
Runtime error (func=(main), adr=12): Function l not defined.
In tcsh:
alias semitone 'echo "scale=10; e(l(2.)/12.)" | bc'
works totally fine and gives correct output:
1.0594630943
I also attempted using a bash function:
semitone() { echo "scale=10; e(l(2.)/12.)" | bc ; }
which returns the same bc runtime error. Not sure how the output is getting munged. Any insight?