LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 04:10 AM   #1
mierdatuti
Member
 
Registered: Aug 2008
Posts: 64

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, 04:11 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,945

Rep: Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325Reputation: 7325
what will
print "scale=2; $sum/$count"
respond? (without backticks and pipe and bc)
 
Old 04-21-2015, 05: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, 07:32 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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, 07:56 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,377

Rep: Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757
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, 08:13 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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



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-13-2013 11:51 PM
Sudo path variable error andrewbonney Linux - Newbie 2 05-29-2010 03:07 AM
setting environment variable error meetmefar Linux - Newbie 10 12-04-2009 03:53 PM
Snort error on middlebox: Undefined variable name wsduvall Linux - Security 2 02-18-2009 07:56 PM
DISPLAY variable error...cannot set it rameshchandra Linux - General 2 10-09-2005 04:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:26 AM.

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
Open Source Consulting | Domain Registration