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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

ubuntu - Bash Script to Check That Files Are Being Created -