Any ideas? I am attempting to write a script that uses sed.

If done this way it fails

  • rmdec=“sed ‘s/…$//’”
  • i1xmr=$(echo “$i1p/$apiresponse*1000” |bc -l |$rmdec)

But if i do it this way it works

  • i1xmr=$(echo “$i1p/$apiresponse*1000” |bc -l | sed ‘s/…$//’)
  • bizdelnick@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    Again, you don’t need sed for this, simply set scale=2 or how many digits after decimal point you need. Also you missed ! in the shebang (#!/bin/bash or #!/bin/sh).

    • shortwavesurfer@monero.townOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      So I need five digits after the decimal point, but then when I do the multiplication, I only want four digits in total. I did move “scale=” to five and that made the sed command in rmdec much shorter, but its still needed. I thought i could add “length=4” but that throws an error.