3
1
I often use the less
pager to view logfiles. Usually I use less -F
to follow the progress of the log à la tail
.
However, some logfiles use national characters in a non-standard encoding (Latin-1, while the system uses UTF-8). Obviously, these will not be displayed correctly.
How can I view such files with less
?
The only solutions I found:
- Correct the encoding of the file (
recode
oriconv
). This does not work while the file is still being written, so does not let me useless -F
. Plus it destroys the logfiles original timestamp, which is bad from an auditing perspective. - Use a pipe (
recode latin1... |less
). Works for files in progress, but unfortunately thenless -F
does not appear to work (it just does not update; I believe therecode
process exits once it's done).
Any solution that lets me "tail" a logfile and still shows national characters correctly?
It looks from
man less
like there is a preprocessor which you could possibly set to fix your encoding. – isomorphismes – 2018-05-12T10:11:10.067@isomorphismes: Yes,
less
does support calling a preprocessor. However, as far as I can tell, the preprocessor reads the input file and creates a new file forless
, so this would not work forless -F
. – sleske – 2018-05-12T20:12:56.397