sed

在每行的头添加字符,比如"HEAD",命令如下:

sed 's/^/HEAD&/g' -i test.file

在每行的行尾添加字符,比如“TAIL”,命令如下:

sed 's/$/&TAIL/g' -i test.file

在匹配的开始的第3行,插入指定内容,命令如下:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection
sed -e '/Identifier "libinput touchpad catchall"/{n;n;n;/Driver/a\        Option "Tapping" "on"' -e '}' -i 40-libinput.conf

参考文章

  1. Sed命令n,N,d,D,p,P,h,H,g,G,x解析
  2. linux:sed高级命令之n、N

results matching ""

    No results matching ""