Ubuntu – Ending tail -f after print n lines

bashcommand linetail

I have the following.

  1. A Java process writing logs on file
  2. A shell script starting
    the Java process.

I need to read the log file after start Java process to check correct starting.

I have try with tail -f but it remain append forever. I need tail stop after print n lines. There is a way like -n option for previuos lines?

Best Answer

You can pipe the output of tail -f to head to limit the amount of lines shown:

tail -f [PATH] | head -n 100

to only show 100 lines in total.

Related Question