Home » Questions » Computers [ Ask a new question ]

Unix command to empty logfile from within "less"?

Unix command to empty logfile from within "less"?

I prefer using "less" to reading logfiles. As opposed to "tail -f" I can both follow (Shift + F), stop (Ctrl + C), and navigate up and down u and d, etc.

Asked by: Guest | Views: 224
Total answers/comments: 2
Guest [Entry]

"The easiest way IMHO is:
!>%
That is: Exception mark ""!"", greater sign "">""and percentage sign ""%"".
Maybe it helps."
Guest [Entry]

The easiest I can think of is probably to use ^Z to put the current process in the background, remove your files, and type fg to go back to your process. That said, removing log files is not the best way to deal with them, it's much better usually to use logrotate to compress them.