LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-19-2011, 05:13 PM   #1
fjcc90
LQ Newbie
 
Registered: Jul 2011
Distribution: RHEL 5
Posts: 1

Rep: Reputation: Disabled
(standard_in) 1: parse error setting variable with bc


I'm trying to define a variable, CHAN, by dividing another variable, FREQ, by a number. FREQ is a value from a file (called header.txt). What I think I'm doing with this bit of code is reading a number from header.txt whose location is specified by the head and tails, assigning it to FREQ and then defining CHAN with bc.

Code:
#!/bin/bash
while read FREQ
        do tail -n +7 | tail -c +11 | head -c 8
done<header.txt
CHAN=`echo "$FREQ / 1.28"|bc`
However, when I run this I get the error: (standard_in) 1: parse error. I suspect the problem is with how I am reading the value of FREQ because if I run this:
Code:
FREQ=4
CHAN=`echo "$FREQ / 1.28"|bc`
it returns 3, which is right (sort of).

Any ideas on how to fix this?
Thanks
 
Old 07-19-2011, 06:54 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
If you use
Code:
set -xv
as the 2nd line of your script ie immediately after #!/bin/bash, it'll show you exactly what's happening in detail. Great for debugging.
 
Old 07-20-2011, 03:59 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Chris' advice is sound. I would also ask what you think the while loop is doing?
I would suggest looking back at whatever source you use for bash information to see how this construct works.
 
  


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
Assigning Structure object's variable outside main() gives parse error thelink123 Programming 7 09-03-2010 07:41 AM
PHP Error Parse error: parse error, unexpected $ in /home/content/S/k/i/SkinCare4U/h CowanServices Programming 2 12-09-2008 09:26 PM
Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.p Scooby-Doo Programming 3 10-25-2007 10:41 AM
bash bc (standard_in) 1: parse error hta1984 Programming 8 12-13-2006 03:34 PM
(standard_in) 1: parse error timmay9162 Programming 8 04-26-2006 03:32 AM


All times are GMT -5. The time now is 06:49 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