I have a log file encoding with gbk, I have to read the data like this:
tail -n 2000 nohup.out | iconv -f gbk -t utf-8
but when I use tail -f
it will print nothing:
tail -f nohup.out | iconv -f gbk -t utf-8
I have a log file encoding with gbk, I have to read the data like this:
tail -n 2000 nohup.out | iconv -f gbk -t utf-8
but when I use tail -f
it will print nothing:
tail -f nohup.out | iconv -f gbk -t utf-8
In a similar situation I use a script that reads each line and convert. In your case: tail -f nohup.out | iconv.sh
#!/bin/bash
#iconv.sh
IFS=''
while read line
do
echo "$line" | iconv -f gbk -t utf-8
done < "${1:-/dev/stdin}"
© 2022 - 2024 — McMap. All rights reserved.