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