Conservative. Idaho. Software engineer. Historian. Trying to prevent Idiocracy from becoming a documentary.
Email complaints/requests about copyright infringement to clayton @ claytoncramer.com. Reminder: the last copyright troll that bothered me went bankrupt.
"And we know that all things work together for good to them that love God, to them who are the called according to his purpose." -- Rom. 8:28
Pages
▼
Friday, May 31, 2024
Bash Scripts amd Seq
Every time I write a bash script that requires floating point indexing, I forget the seq command.
for z in $(seq 0 -.01 1)
do
echo $z
done
Darn useful and I hope writimg it dowmn wil burn it into permanent memory this time.
syntax error... count from 0 to 1 in -.01 increments? you'll never get there. seq 0 .01 1 or seq 1 -.01 0 would work better... :)
there are fancy ways to make brace expansion simulate decimals and using built-ins is almost always better but those are tougher to remember and the seq command and my mental filing cabinet is too full these days for goofy programming golf exercises...
syntax error...
ReplyDeletecount from 0 to 1 in -.01 increments? you'll never get there.
seq 0 .01 1 or seq 1 -.01 0 would work better... :)
there are fancy ways to make brace expansion simulate decimals and using built-ins is almost always better but those are tougher to remember and the seq command and my mental filing cabinet is too full these days for goofy programming golf exercises...
Yes 0 -.01 -1
Delete