获取“sed 错误 - 非法字节序列"(在 bash 中) [英] Getting "sed error - illegal byte sequence" (in bash)

查看:18
本文介绍了获取“sed 错误 - 非法字节序列"(在 bash 中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进行一些流编辑以更改讨厌的 Parallels 图标.它的开发很差并嵌入到应用程序本身中,而不是一个图像文件.所以我找到了这个 sed 命令,它有一些很好的反馈:

Doing some stream editing to change the nasty Parallels icon. It's poorly developed and embedded into the app itself rather than being an image file. So I've located this sed command that has some good feedback:

sudo sed -i.bak s/Parallels_Desktop_Overlay_128/Parallels_Desktop_Overlay_000/g /Applications/Parallels Desktop.app/Contents/MacOS/prl_client_app

返回sed:RE错误:非法字节序列

谁能解释一下这是什么意思?命令的哪一部分有问题?

Can anyone explain what this means? What part of the command is the problem?

推荐答案

尝试设置 LANG 环境变量 (LANG=C sed ...) 或使用其中之一这里提到的二进制 sed 工具:二进制 sed 替换

Try setting the LANG environment variable (LANG=C sed ...) or use one of the binary sed tools mentioned here: binary sed replacement

为什么会出错?

没有 LANG=C sed 假定文件以 LANG 中指定的任何编码进行编码,并且文件(二进制)可能包含在LANG 的编码(因此您可能会得到非法字节序列").

Without LANG=C sed assumes that files are encoded in whatever encoding is specified in LANG and the file (being binary) may contain bytes which are not valid characters in LANG's encoding (thus you could get 'illegal byte sequence').

为什么 LANG=C 有效?

Why does LANG=C work?

C 恰好将所有 ASCII 字符视为它们本身,将非 ASCII 字符视为文字.

C just happens to treat all ASCII characters as themselves and non-ASCII characters as literals.

这篇关于获取“sed 错误 - 非法字节序列"(在 bash 中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆