LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-21-2015, 05:10 AM   #1
mierdatuti
Member
 
Registered: Aug 2008
Posts: 53

Rep: Reputation: 15
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?
 
Old 04-21-2015, 05:11 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,500

Rep: Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431Reputation: 2431
what will
print "scale=2; $sum/$count"
respond? (without backticks and pipe and bc)
 
Old 04-21-2015, 06:07 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

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

Code:
which print
would show one if exists.
 
Old 04-21-2015, 08:32 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,476
Blog Entries: 10

Rep: Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639
If this is a script of some type, perhaps you can post the rest of it, because where are $sum and $count defined?
 
Old 04-21-2015, 08:56 AM   #5
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,461

Rep: Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368
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.
 
Old 04-21-2015, 09:13 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,476
Blog Entries: 10

Rep: Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] error while storing output in variable project.linux.proj Linux - Newbie 4 02-14-2013 12:51 AM
Sudo path variable error andrewbonney Linux - Newbie 2 05-29-2010 04:07 AM
setting environment variable error meetmefar Linux - Newbie 10 12-04-2009 04:53 PM
Snort error on middlebox: Undefined variable name wsduvall Linux - Security 2 02-18-2009 08:56 PM
DISPLAY variable error...cannot set it rameshchandra Linux - General 2 10-09-2005 05:59 AM


All times are GMT -5. The time now is 04:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration