3 ms·
echo "1\n2\n3\n" | tr '\n' + | bc
by atondwal 13y ago
echo "1\n2\n3\n" | tr '\n' + | bc
- FreeFull 13y agoDoesn't work. By default, echo doesn't translate \n into a newline, so you have to add the -e flag. Then, bc doesn't like the extra plusses at the end, so you have to either add the -n flag to echo and remove the last \n, or somehow trim the newlines from the end beforehand.
- jbert 13y agoThanks for the detail. I was worried about the escapes in the echo, but didn't check.