

InterviewSolution
Saved Bookmarks
1. |
Solve : Need help with a Script? |
Answer» I am trying to run a script called f2c with the following formula: I am trying to run a script called f2c with the following formula: is it a single quote you are using for 'expr...' ?? you should try backquote ` .... I am using a single quote, but when I use the backquote `, I get a syntax error.This is the correct syntax: #! /bin/sh -f #f2c TEMP=$[ ( $1 - 32 ) * ( 5 / 9 ) ] echo "The Celsius temp is: ${TEMP}"but it won't do what you expect. Bash/sh evaluates 5/9 to 0 - no decimals. If you want to do precision arithmetic, tryman bcyou can try this : Code: [Select]results=$(printf "%s\n" 'scale = 2; ($1-32) * 5/9' | bc) echo $results |
|