Support Questions

Find answers, ask questions, and share your expertise

How to get the last n lines of a text file ("tail -n log.file")

avatar
Contributor

Hi,

 

An external process creates an error.file on certain events and updates the process log file.

 

The process that I'm creating starts when the error.file is created and need to read the last 10 - 15 lines of the log.file. My problem is that the log.file does not rollover and just grows continually and neither follows a log standard in order to use SysLog processors.

 

How can I get that last 10 - 15 lines of the log file? Something like ( "tail -15 log.file" ).

 

Thanks in advance.

1 ACCEPTED SOLUTION

avatar
Super Guru

Hi @templarian ,

 

You can use something like the example below:

araujo_0-1648594388252.png

 

araujo_1-1648594412531.png

Cheers,

André

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

View solution in original post

2 REPLIES 2

avatar
Super Guru

Hi @templarian ,

 

You can use something like the example below:

araujo_0-1648594388252.png

 

araujo_1-1648594412531.png

Cheers,

André

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Contributor

Hi André,

 

That is what I needed. Thanks a lot.

 

For those who are facing the same problem in windows; @araujo's solution also works with Powershell

 

Nifi ExecuteStreamCommand Powershell.png