0

I'm using FSL (a neuroimaging programme) and I have a for loop to analyse all my participants. The line in question is :

fslstats <FILENAME> -M -V | awk '{print $1 * $3 }'

How do I get the awk function to print the whole number, rather than something like 9.37157e+07

Thanks in advance

0

1 Answer 1

1

If you want something specific, you'll have to supply a format, e.g.,

fslstats <FILENAME> -M -V | awk '{printf "%d\n", $1 * $3 }'

or

fslstats <FILENAME> -M -V | awk '{printf "%f\n", $1 * $3 }'
4
  • 1
    This will print in non-floating format, but generally not more than 16 significant digits if that's what OP meant by 'full number'. Unless you have recent GNU awk and use -M/--bignum. Aug 7, 2020 at 3:30
  • OP didn't say that. The example given has no more than 8 digits: 9.37157e+07. Aug 7, 2020 at 7:45
  • The format for print is set by OFMT, and default is "%.6g", which switches to scientific notation if the result is more than a few digits. printf "%f" defaults to "%.6f", which rounds to 6 decimal digits. The format "%.15f" will give you a fixed.format with 15 digits after the point, and %.15g will defer the switch to scientific notation. Aug 7, 2020 at 15:18
  • @ThomasDickey Not necessarily 8 digits: echo 9.3715688345626 | awk '{ print 1e7 * $1 }' yields 9.37157e+07. Aug 7, 2020 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .