How can I check using Linux / Bash how many lines were added to selected log file during for example last 10 seconds ?
It's one time use, not on to run in the background.
File doesn't contain any information about time.
I also don't need this arbitrary -> I can select a moment from when I would like to track the number of rows added, and do this for some time.
Thanks!
Then it's a lot harder, no utility does this out of the box because if it did, it would imply that it knew about the files contents 10 seconds ago. But, there is nothing magical about "10 seconds" that would mean write data is kept/buffered for that long (unless there is some secondary logging about what it wrote to the log file, and when).
Your best bet is to either:
tail -s 10 -f FILE
so it outputs the contents of the file in 10 second blocks.echo '-- MARKER --' >> FILE
and check back for what you want.But, either way, you'll need to roll your own solution.
You can set up a job that will log time and number of lines in the file. Alternate way would be to insert timestamp in the log file and check number of lines between timestamps.
You cannot do this unless you know you will need to do it in advance (which would allow you to copy the file or snapshot the filesystem at the right time). Even versioned filesystems (which are rare) don't log each character or line that changes as it changes. The best you could ever hope to achieve would be to say "The last change was this data and it happened between time X and time Y".
Based on Zoredache's answer: it looks like timeout also kill pipe, but you still can forward the output to some temporary file and then count the lines in it.
or with watch