i have a logfile, a script checks this log-file every hour it shall pack the 3rd word of the last matching line into a variable but i didn't manage it to work yet ..
logfile:
2018-11-18 22:27:10 1542576430 c2- restarted=true
2018-11-19 00:14:34 1542582874 c2- restarted=true
search for last line with c2- and pack this line int variable "lastline"
lastline=$(tac $logfile | grep -m1 c2-)
now put the 3 string of this line into a variable:
last=$(awk '{print $3}' $lastline)
But that does not work ..
especially it does not work wenn i try:
lastline=$(tac $(awk '{print $3}' $lastline) | grep -m1 c2-)
So can anyone help me ??? at the moment i have absolutely no clue .. the output is always:
awk: cannot open 2018-11-19 (No such file or directory)