且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在bash编程中替换多行文本

更新时间:2023-12-04 13:01:28

如果您不介意使用 Perl ,请尝试:

if you do not mind using Perl try:

~ ❱ perl -pe 's/ ((?=[a-z]).)/" ".chr(ord($1)+3)/eg' file
text := d \
        e \
        f 
~ ❱ 

您字符的ASCII码是: 100 101 102
因此,如果您向他们添加 3 ,它们从 a b c 变为 d e f

the ASCII code for your character is: 100, 101 and 102
Thus if you add 3 to them they from a b c become d e f