2 Answers
2

There are a couple of issues with your awk need to pass the variables using the -v option and use the BEGIN block as no input is given. Also note that a single > will not append but overwrite the file. For appending you need >>:

I can't seem to get this to work in a script
–
mark mcmurrayFeb 13 '13 at 15:59

It's hard to say what mistake you have made without posting your code but this is tested and works ideone.com/cd21JU I have pointed out the awk mistakes but the right solution is too use echo.
–
iiSeymourFeb 13 '13 at 16:06

Will I need to do '>> $RSSI_CSV' to append the result?
–
mark mcmurrayFeb 13 '13 at 15:55

Yes, ">" alone would overwrite the file. The benefit of using printf here is that it is a shell built-in, so it doesn't have to spawn a new process just to add to the file. I'll update the answer to handle appends better.
–
chepnerFeb 13 '13 at 15:59

printf is not necessarily any more of a shell builtin than is echo.
–
William PursellFeb 14 '13 at 10:13

@EdMorton: Could you provide an example where using "%s" produces a different result than direct interpolation? @WilliamPursell No, echo would work just as well. I just meant to contrast printf with awk.
–
chepnerFeb 14 '13 at 12:56