-   Linux - Newbie (
-   -   tail -f as variable input into a script (

willyjc1 06-30-2011 11:08 AM

tail -f as variable input into a script
I have a file which is continuously receiving new data throughout the day. Currently I use the tail -f command to view the last line to be written to the file as it happens in realtime. However, the data that I am reading in the format of a long, non-delimited string that looks like this:


I wrote a script to parse the string and return only the info that i want in a readable form and it works fine. But I am simply using a sample string as the value of variable $x in the script to test it. In other words...


What I NEED is to have the last line of the file read into the script as the file is updated and set equal to the variable $x. And then of course overwritten each time a new line is written to the file so that the script will return to me the PARSED VERSION of the string to appear on my screen in realtime. Can this be done??

Help will be greatly appreciated!

colucix 06-30-2011 11:16 AM

Something like this?

while read line
  echo The new line is: $x
done < <(tail -f file)

willyjc1 06-30-2011 11:35 AM

Thanks, let me try that.

All times are GMT -5. The time now is 06:18 AM.