Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-08-2013, 06:45 AM   #1
Sanpreet Singh
Registered: Jan 2013
Location: Malout,Punjab
Distribution: Ubuntu(Debian), Windows
Posts: 36
Blog Entries: 1

Rep: Reputation: Disabled
Bash Scripting

I want a help on bash scripting.I am explaining the problem now.

I am reading the output from the serial port(ttyUSB0). Now I want to draw the graph from the readings that I have obtained. The reading are Linked here by me as

Now in the above link in one line there are two readings. I want to do caliberation of both the reading. SO from one line how can I make the caliberation of two different readings. How to store these two readings. How the bash will know which reading is from which?

Is there any way to store this values.

I am writing the bash script that has read from the serial port.

cat /dev/ttyUSB0
while true; do
read LINE < /dev/ttyUSB0
echo $LINE

Any solution will be most welcomed.
Attached Thumbnails
Click image for larger version

Name:	TCC_Screen_Shot.png
Views:	21
Size:	32.3 KB
ID:	12675  
Old 06-08-2013, 10:27 AM   #2
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,527

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
Well I am not sure I follow, but why not just read the values into 2 variables?
while read -r var1 var2
Old 06-09-2013, 08:04 AM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
As grail said.

How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?

BTW, "/usr/bin/bash"? In nearly all cases shell interpreters are kept in /bin. Unless you have some different version installed that you want to use instead?

And please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques. Thanks.


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
bash scripting and tr zunder1990 Linux - Newbie 11 03-15-2011 02:39 PM
Bash Scripting for TC CraigAaron Programming 3 03-02-2011 06:24 PM
bash scripting ZAMO Linux - General 1 12-04-2008 02:53 AM
Reading a bash variable in bash scripting problem freeindy Programming 3 11-27-2008 02:29 AM
bash scripting -=MaGo=- Programming 16 08-30-2003 07:07 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:58 PM.

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