Comparing a number in a text file with a specific value
My project is to get a temperature reading from a refridgerator every 2 minutes and check to see if the door has been left open.
I don't yet have the mastery of Linux, being a complete noob, but I reckon I need a text file with the latest temperature reading in it. This I've managed to do by getting cron to call up a script called fridgedoor every 2 minutes and outputting the result from Digitemp (serial temperature reader) to fridgedoor.txt.
So every 2 minutes fridgedoor.txt is overwritten with the current temperature. The file just has a number in it e.g "3.06"
So I've got line 1 of my script done and dusted.
My next job is to get it to play a .wav if the temperature is greater than 5.00
Aaaah! My knowledge of commands was pretty well used up on line 1.
I know I start with if and end with fi. It's just the teensy weensy bits in the middle I'm clueless about.
Anybody want to help a knackered old sop like me out with the middle bit?
Thanks for the quick reply
Hit a bit of a snag though...
The script is:
I've left out the sleep 120 as cron does that.
Q: Is while do a never ending loop?
Anyway!
Typing in the command line:
brafferton@cameras:~/Downloads$ fridgedoor
gets:
/usr/bin/fridgedoor: line 6: 2.88 > 5.00 : syntax error: invalid arithmetic operator (error token is ".88 > 5.00 ")
---------- Post updated at 11:04 PM ---------- Previous update was at 08:45 PM ----------
I've been doing a lot of trawling and I think that either the CR at the end of the line, (and I presume there is one) is cocking up everything OR that bash won't do decimals, or both
If it's not the CR thingy then how would I strip the decimals off fridgedoor.txt i.e. if 6 > 5 then sound the alarm?
---------- Post updated 28-01-11 at 08:49 AM ---------- Previous update was 27-01-11 at 11:04 PM ----------
More trawling overnight and I've managed:
No Errors!
Seems to work...
Last edited by Yogesh Sawant; 02-01-2011 at 07:53 AM..
Reason: added code tags
Hi
This is my first post and I'm just a beginner. So please be nice to me.
I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file?
I have tried sed -n 241,241p... (13 Replies)
Hi,
I have a value stored in x and I need to compare it to the numbers in every other line of a file. The file contains alternating lines of numbers and letters:
aaaa1111
AAAAAAAA
bbbb2222
BBBBBBBB
cccc3333
CCCCCCCC
I need to compare x to the numbers in every other line without the... (2 Replies)
I have this space delimited large text file with more than 1,000,000+ columns and about 100 rows. I want to delete all the cells that consist of just 2 (leave 2's that are not by themselves intact):
File before modification
aa bb cc 2 NA100 dd
aa b1 c2 2 NA102 de
File after modification... (1 Reply)
Hi, Good day.
I currently have this data called database.txt and I would like to check if there are no similar values (all unique) on an entire row considering the whole column data is unique. the data is as follows
cL1 cL2 cL3 cL4
a12 c13 b13 c15
b11 a15 c19 b11
c15 c17 b13 f14
with... (1 Reply)
hi,
I need a script which can format the below text file which contains comments
file1.txt
--------
//START
//Name: some value
//Date:
//Changes:.............
//.....................
//END
//START
//Date:
//Name: some value
//Changes:.............
//..................... (3 Replies)
Hello! All,
Could you please tell me how to get a specific line number from a text file?
For example below,
ABC
DEF ---> Get this line number, return to an variable
GHI
My OS is Linux.
Thank you so much for your help in advance! (3 Replies)
Hi,
I have the following text file:
8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm
9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm
10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm
11 T1mapping_flip15 ok 128 108 30... (2 Replies)
I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it.
For example, Here is a portion of a zone file.
IN NS ns1.domain.tld.
IN NS ns2.domain.tld.
IN ... (2 Replies)
Hi
I want to extract certain text between two line numbers like
23234234324 and
54446655567567
How do I do this with a simple sed or awk command?
Thank you.
---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ----------
found it:
sed -n '#1,#2p'... (1 Reply)
Hi,
I wanted to add specific text to each row in a text file containing three rows. Example:
0 8 7 6 5 5
7 8 9 0 7 9
7 8 9 0 1 2
And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this:
21 0 8 7 6 5 5
7 8... (4 Replies)