从文件中删除所有非 utf-8 字符,终端中没有输出

Nim*_*odi 3 ubuntu utf-8 output

我是一个新的 Ubuntu 用户,正在处理一个非常大的文件,其中包含一些可以安全跳过的非 utf8 字符。我发现了另一个堆栈溢出问题How to remove non UTF-8 characters from text file that give a way to remove those characters, using the command

iconv -f utf-8 -t utf-8 -c file.txt
Run Code Online (Sandbox Code Playgroud)

但是对于我的文件的大小,这会输出每一行,这需要太多时间。我对 Ubuntu 命令不太熟悉,所以如果有人能指导我修改该命令以抑制输出,我将不胜感激

Ala*_*ack 5

使用 shell 重定向将转换输出到新文件:

iconv -f utf-8 -t utf-8 -c file.txt > new-file.txt
Run Code Online (Sandbox Code Playgroud)

然后检查新文件的结尾:

tail new-file.txt
Run Code Online (Sandbox Code Playgroud)

检查顶部:

head new-file.txt
Run Code Online (Sandbox Code Playgroud)