gpt4 book ai didi

linux - 有没有办法在 sed 中获取字符的 ASCII 码?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:09:27 24 4
gpt4 key购买 nike

我正在编写一个 sed 脚本,其中的一部分需要用 ASCII 代码的十六进制值替换某个子集中的字符。我做了一些研究,但找不到任何东西,所以我开始认为 sed 没有让我这样做的功能。如果这里有sed高手,请赐教吗?

P.S.:sed -e "s/A/41/g"-e "s/B/42/g"... 等 之类的解决方案是行不通的。

最佳答案

如果 perl 是您的可行替代方案,那么:

fge@erwin ~ $ perl -pe 's,[abcRte], ord($&) ,ge'
oiiiiisdfa
oiiiiisdf97
abcRte
97989982116101

关于linux - 有没有办法在 sed 中获取字符的 ASCII 码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8623483/

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