更新时间:2021-08-06 23:07:35
您可以使用
sed 's/^AAA_1[0-9]*/BBB_2/' infile.txt > outfile.txt
请参见在线 sed
演示.
此正则表达式匹配
^
-行首- AAA_1
-文字子字符串 [0-9] *
-零个或多个数字(如果要表示非空格,则可以将其替换为 [^] *
)^
- start of a line
-AAA_1
- a literal substring[0-9]*
- zero or more digits (if any non-space is meant, you may replace it with [^ ]*
)