So I'm trying to complete the first section at the moment, check if the last two lines of the file matches a certain string to verify that failloging is enabled.
I'm testing this with the following enviroment; I have a file named test with four lines:
Code:
line 1
line 2
line 3
line 4
After a lot of playing around I got this bit of code to work:
Code:
if [ "`tail -2 test`" != "`echo -e "line 3\nline 4"`" ]
then
echo -e "Requirements not found\nAppending..."
echo -e "line 3\nline 4" >> test
echo "Next Step"
else
echo -e "Requirements found\nNext Step"
fi
It tests to see if the last two lines of file test are NOT "line 3\nline 4", if it is does NOT match then it adds "line 3\nline 4" as well as some other stuff just so I can see what the script is doing. If it DOES match then it moves onto the next step, which I think I'll start on tomorrow.