0

I have a process which is dumping data to a file. It is a list of transactions and typically is about 3.8G in size.

to do a tail -f file.txt is not very useful, however, each batch of transactions begins with:

START TRANSACTION: xyz

and there are only a couple hundred of those.

Is there any way to combine tail -f and grep "START TRANSACTION:" in such a way to get the following output:

START TRANSACTION: abc
START TRANSACTION: def
START TRANSACTION: ghi
...

dynamically?

3

1 Answer 1

3

Reading the SO question you linked, it seems like:

tail -f -n +1 file.txt | grep "START TRANSACTION"

should do what you want. The -n option tells tail how many lines to output (if given a plain number); if instead given a number starting with +, it starts from that line. So that'll start from the first line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.