gpt4 book ai didi

sed - 有没有办法创建一个 sed 或 awk 语句来用另一个范围的字符替换代码中的字符

转载 作者:行者123 更新时间:2023-12-02 05:42:26 25 4
gpt4 key购买 nike

背景:MS 向存在严重磨损问题的 OEM 发布了 COA 标签。使用的碳粉未正确粘合到 COA 标签纸上。随着时间的推移,产品 key 降级并且某些字母/数字不再可读,从而禁止输入授权 key 进行重新安装。

问题:当只有几个字母/数字损坏时,尝试确定之前尝试过的数字是非常令人沮丧的。

请求:利用sed或awk(最好)或其他方法输入一个字符串,例如

A{B,E,R,8}CDE-FGH{I,1}J-KLMN{O,Q,0}-PQRST-UVWXY

并接收

的输出
ABCDE-FGHIJ-KLMNO-PQRST-UVWXY
AECDE-FGHIJ-KLMNO-PQRST-UVWXY
ARCDE-FGHIJ-KLMNO-PQRST-UVWXY
A8CDE-FGHIJ-KLMNO-PQRST-UVWXY
ABCDE-FGH1J-KLMNO-PQRST-UVWXY
AECDE-FGH1J-KLMNO-PQRST-UVWXY
ARCDE-FGH1J-KLMNO-PQRST-UVWXY
A8CDE-FGH1J-KLMNO-PQRST-UVWXY
ABCDE-FGHIJ-KLMNQ-PQRST-UVWXY
AECDE-FGHIJ-KLMNQ-PQRST-UVWXY
ARCDE-FGHIJ-KLMNQ-PQRST-UVWXY
A8CDE-FGHIJ-KLMNQ-PQRST-UVWXY
ABCDE-FGH1J-KLMNQ-PQRST-UVWXY
AECDE-FGH1J-KLMNQ-PQRST-UVWXY
ARCDE-FGH1J-KLMNQ-PQRST-UVWXY
A8CDE-FGH1J-KLMNQ-PQRST-UVWXY
ABCDE-FGHIJ-KLMN0-PQRST-UVWXY
AECDE-FGHIJ-KLMN0-PQRST-UVWXY
ARCDE-FGHIJ-KLMN0-PQRST-UVWXY
A8CDE-FGHIJ-KLMN0-PQRST-UVWXY
ABCDE-FGH1J-KLMN0-PQRST-UVWXY
AECDE-FGH1J-KLMN0-PQRST-UVWXY
ARCDE-FGH1J-KLMN0-PQRST-UVWXY
A8CDE-FGH1J-KLMN0-PQRST-UVWXY

最佳答案

你在命令行上试过这个吗?至少在 bash 中,它“正常工作”:

> echo A{B,E,R,8}CDE-FGH{I,1}J-KLMN{O,Q,0}-PQRST-UVWXY
ABCDE-FGHIJ-KLMNO-PQRST-UVWXY ABCDE-FGHIJ-KLMNQ-PQRST-UVWXY ABCDE-FGHIJ-KLMN0-PQRST-UVWXY ABCDE-FGH1J-KLMNO-PQRST-UVWXY ABCDE-FGH1J-KLMNQ-PQRST-UVWXY ABCDE-FGH1J-KLMN0-PQRST-UVWXY AECDE-FGHIJ-KLMNO-PQRST-UVWXY AECDE-FGHIJ-KLMNQ-PQRST-UVWXY AECDE-FGHIJ-KLMN0-PQRST-UVWXY AECDE-FGH1J-KLMNO-PQRST-UVWXY AECDE-FGH1J-KLMNQ-PQRST-UVWXY AECDE-FGH1J-KLMN0-PQRST-UVWXY ARCDE-FGHIJ-KLMNO-PQRST-UVWXY ARCDE-FGHIJ-KLMNQ-PQRST-UVWXY ARCDE-FGHIJ-KLMN0-PQRST-UVWXY ARCDE-FGH1J-KLMNO-PQRST-UVWXY ARCDE-FGH1J-KLMNQ-PQRST-UVWXY ARCDE-FGH1J-KLMN0-PQRST-UVWXY A8CDE-FGHIJ-KLMNO-PQRST-UVWXY A8CDE-FGHIJ-KLMNQ-PQRST-UVWXY A8CDE-FGHIJ-KLMN0-PQRST-UVWXY A8CDE-FGH1J-KLMNO-PQRST-UVWXY A8CDE-FGH1J-KLMNQ-PQRST-UVWXY A8CDE-FGH1J-KLMN0-PQRST-UVWXY

或在单独的行上/在其他一些命令中使用:

> for a in A{B,E,R,8}CDE-FGH{I,1}J-KLMN{O,Q,0}-PQRST-UVWXY; do echo $a; done
ABCDE-FGHIJ-KLMNO-PQRST-UVWXY
ABCDE-FGHIJ-KLMNQ-PQRST-UVWXY
ABCDE-FGHIJ-KLMN0-PQRST-UVWXY
ABCDE-FGH1J-KLMNO-PQRST-UVWXY
ABCDE-FGH1J-KLMNQ-PQRST-UVWXY
ABCDE-FGH1J-KLMN0-PQRST-UVWXY
AECDE-FGHIJ-KLMNO-PQRST-UVWXY
AECDE-FGHIJ-KLMNQ-PQRST-UVWXY
AECDE-FGHIJ-KLMN0-PQRST-UVWXY
AECDE-FGH1J-KLMNO-PQRST-UVWXY
AECDE-FGH1J-KLMNQ-PQRST-UVWXY
AECDE-FGH1J-KLMN0-PQRST-UVWXY
ARCDE-FGHIJ-KLMNO-PQRST-UVWXY
ARCDE-FGHIJ-KLMNQ-PQRST-UVWXY
ARCDE-FGHIJ-KLMN0-PQRST-UVWXY
ARCDE-FGH1J-KLMNO-PQRST-UVWXY
ARCDE-FGH1J-KLMNQ-PQRST-UVWXY
ARCDE-FGH1J-KLMN0-PQRST-UVWXY
A8CDE-FGHIJ-KLMNO-PQRST-UVWXY
A8CDE-FGHIJ-KLMNQ-PQRST-UVWXY
A8CDE-FGHIJ-KLMN0-PQRST-UVWXY
A8CDE-FGH1J-KLMNO-PQRST-UVWXY
A8CDE-FGH1J-KLMNQ-PQRST-UVWXY
A8CDE-FGH1J-KLMN0-PQRST-UVWXY

或者您可能已经知道这一点并且出于其他原因需要 sed/awk?

关于sed - 有没有办法创建一个 sed 或 awk 语句来用另一个范围的字符替换代码中的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10762524/

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