我正在寻找使用sed命令替换子字符串值。
我有一个像这样的文件
UNIT56712423MP000000R0990
此文件中的记录始终具有相同的长度。
我需要检查第21个字符是否为R
,然后将字符13-14从MP
替换为GH
。
是否可以通过sed命令实现此目标?
感谢您的帮助。
答案 0 :(得分:0)
在gnu sed上尝试
- Make an infinite loop with logical variable condition set to 1
- Within the loop when stopping loop criteria rises set the logical
variable condition to 0
- loop will no longer run
count = 0;
stop = 11;
condition = 1;
while condition
count = count + 1;
--> do all the calculations before checking
condition = ~(a == 5 || count == stop);
--> do all the remaining calculations then exit from the loop
end