Hello Linux fans. I am kinda new to Linux and Bash scripting and would like to read through a log file looking for a word, then extract a value later on that line.
Here is a sample of my log file
07/17 21:04:01 sndc addr unit 1 : hu P1 (TempLinc) 07/17 21:04:02 sndc func StatusReq : hc P 07/17 21:04:04 rcvi addr unit 15 : hu P15 (TempAck_5) 07/17 21:04:04 rcvi func Preset : level 11 07/17 21:04:04 Temperature = 78 : hu P0 (office_temp) 07/17 21:19:01 sndc addr unit 1 : hu P1 (TempLinc) 07/17 21:19:02 sndc func StatusReq : hc P 07/17 21:19:05 rcvi addr unit 15 : hu P15 (TempAck_5) 07/17 21:19:05 rcvi func Preset : level 11 07/17 21:19:05 Temperature = 78 : hu P0 (office_temp)
I have the beginnings of a script that can read the file line by line, thus:
#!/bin/bash fil=/home/heyu.log.ttyS0 #test for existence of the heyu log file if [ -f $fil ] then #read through the file looking for the word Temperature = while read line do echo $line Ok, do something here done < $fil fi
I want to search the line for the word "Temperature = ", then get the value in a variable.
I think I can figure the rest out.
Thanks for your help,