2
29/0.060

Is there any way to do above floating operation in shell script. I tried these

awk '{printf $1/0.060}' <<<29 It works fine,

awk '{printf $1/0.060}' <<<$test where test=29 also works fine.

But not

awk '{printf $1/$test2}' <<<29 where test2=0.060 Resulting 1, but answer is 483.333

DavidPostill
  • 162,382

1 Answers1

2

The problem is that awk expands positional parameters from parsed input, but not shell variables. What you need therefore is:

awk '{printf $1/'$test2'}' <<<29

This allows the shell to expand $test2, but not $1.

AFH
  • 17,958