I know my brain is not working as it did before the stroke. I used to maintain a 6000 line ksh script for HP. (Yes, I refactored into slightly less monstrous scripts.)
#!/bin/bashThe error is (standard in) 1: syntax error
bc <for (x=0.0; x>-1.0; x -= 0.01) printf "%f\n" x
EOF
Yes the goal is 0.00 to -1.00 in steps of 0.01.
how about just running "seq 0 -0.01 -1" ?
ReplyDeletethis also gets the job done for me on freebsd, if you wanted to get some fancier arithmetic in there, later:
#!/usr/local/bin/bash
bc << EOF
for(x=0.0; x>-1.0; x-=0.01) print x,"\n";
EOF
echo 'scale= 4; i = 0.00 ; while (i <= 1) { print i, "\n"; i+=.01 }' | bc
ReplyDeleteOr
echo 'scale= 4; for ( i = 0.0; i<=1.0; i+=.01 ) { print i, "\n"}' | bc
Clayton:
ReplyDeleteTry this:
#! /bin/bash
for x in {0..100}
do
printf "%0.2f\n" $(bc -l <<EOF
0-$x/100
EOF
)
done
Awesome. They all work.
ReplyDelete