LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   error in a variable (https://www.linuxquestions.org/questions/linux-newbie-8/error-in-a-variable-4175540305/)

mierdatuti 04-21-2015 04:10 AM

error in a variable
 
Hi,
Someone could help me with these sentence?
Code:

per=`print "scale=2; $sum/$count" | bc`
It says me:
Code:

(standard_in) 1: parse error
Why?

pan64 04-21-2015 04:11 AM

what will
print "scale=2; $sum/$count"
respond? (without backticks and pipe and bc)

veerain 04-21-2015 05:07 AM

OP: Do you really have a command named 'print'.

Code:

which print
would show one if exists.

rtmistler 04-21-2015 07:32 AM

If this is a script of some type, perhaps you can post the rest of it, because where are $sum and $count defined?

allend 04-21-2015 07:56 AM

The use of print suggests that the OP has a script written for ksh, the Korn Shell.
The syntax error arises when it is run in another shell such as bash.

rtmistler 04-21-2015 08:13 AM

I wonder if they intended to use print or perhaps they chose it due to C programming and not realizing that it's not the same in the shell. @OP if your intention was to output the result of that computation, a better choice here would be echo. What would also help would be to overview what you're doing, or trying to accomplish, what script type you're using, and so forth.


All times are GMT -5. The time now is 12:48 PM.