gpt4 book ai didi

linux - sed 替换为十六进制

转载 作者:IT王子 更新时间:2023-10-29 00:48:02 27 4
gpt4 key购买 nike

UTF-8 文件 test.txt:

AAAAAAAAAAAAAA

十六进制是

41 41 41 41 41 41 41 41 41 41

sed s/A/B/g test.txt 有效

sed s/\x41/B/g test.txt 不工作

有些字符是不可打印的,所以我必须使用它们的十六进制,A 只是一个例子。

最佳答案

shell 对其进行预处理,使用单引号。

sed 's/\x41/B/g' test.txt

echo -e \x41 # x41
echo -e '\x41' # A

关于linux - sed 替换为十六进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6889093/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com