How to process only new line of tail -f command from live log file?

Hi,

I want to read a live log file line by line and considering those line which are newly added to file
Below code I am using, which read line but as soon as it read new line from log file its starts processing from very first line of file.

tail -F /logs/COMMON-ERROR.log | while read myline; do
ERROR_CODE=$(echo $ myline | awk -F ' ' '{for (i=1;i<=NF;i++){if($i ~ "^[1-1]" && length($i)==6){print $i}}}')
ERROR_CODE_DET=$(echo $ myline | awk -F ' ' '{print $1" "$2}')
echo "$ERROR_CODE_DET" "$ERROR_CODE"

if [ "$ERROR_CODE" -eq 100021 ] ; then
ERROR_MSG="Route failed. Moving to failed routes pool."
fi
done

Try tail -n0 -F /logs/COMMON-ERROR.log |... .

This thread may also help

tail -n0 -F giving same output after reciving new file in log file .....:confused:

Does it work with --follow=name rather than -F ?

Could it be the upper case F ? from man tail :

May be lower case f does not reopen the file?

My suspicion was that the implied --retry is the problem.

---------- Post updated at 03:21 PM ---------- Previous update was at 02:17 PM ----------

yes, by using tail -f it�s not opening file when it receives new line so entire code fails... :(..

Any suggestion how to implement this without using tail option....please help..

Did you try this?

Try adjusting buffers. man awk (mawk in my case):

so try

tail -f /some/path/logfile |  awk -Winteractive 1 

or use the stdbuf program.

tail -f /some/path/logfile | stdbuf -oL

Example for RudiC's comment.....

awk: option `-W interactive' unrecognized, ignored...

---------- Post updated at 08:32 PM ---------- Previous update was at 08:29 PM ----------

stdbuf: command not found...