My end goal is to read some weather information from a text or xml file, extract the temperature and write it on an image file using convert. I am trying to take it one step at a time learn a little and improve on my bash scrip. Convert works fine calling it from a script and creating an image with a variable's text on it.
Now I want to read from a text file and this is where I am running into problems. Every tutorial on the Internet gives similar examples that fail. My text file is simple
Code:Line one Line 2 Line Three Line four Line 5 Line SIXProduces "[: 11: Line: unexpected operator" five times, if I use the ";" after the [ or not.Code:#!/bin/bash while read LINE do if [ $LINE = *four* ] then echo "contains four" fi done < "sample.txt"
Using double brackets produces "readit.sh: 8: [[: not found" repeat five times if I use the ";" after the bracket or not.
I have tried several different versions of string comparison all which fail, even when I copy the exact example from a website.
What is the proper way to compare a sting in bash? (or to extract a specific line from a text file)
I am using 10.4.3 and have bash version 4.1.5(1)-release (x86_64-pc-linux-gnu)