Grep a specific string from bash script and compare -
Grep a specific string from bash script and compare -
i have big log file a.log, want grep 1 string lastly 10 lines , compare variable (ftp_success_msg), how can that?
something like:
logs='/tmp/a.log' ftp_success_msg="226 transfer complete" if [tail -10 $logs == $ftp_success_msg] ; echo "success" else echo "failed" exit 1 fi
if tail -10 "$logs" | grep -fq "$ftp_success_msg" ; ...
notice how [
not nowadays in status (and if were, require non-optional spaces on both sides).
notice also how variable interpolations in double quotes unless require shell tokenize value , perform wildcard expansion on tokens.
bash
Comments
Post a Comment