This question shows research effort; it is useful and clear
0
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
这就是我在第一个模式显示之前添加文本的方式:
FILE_NAME="folder/myfile.c++"
STR_TO_ADD="string that i want to add"
PATTERN="banana"
ed $FILE_NAME 2>NULL 1>NULL<<EOF
/^$PATTERN
-1
a
$STR_TO_ADD
.
wq
EOF
#!/bin/bash
FILE_NAME="folder/myfile.c++"
STR_TO_ADD="string that i want to add"
PATTERN="banana"
ed $FILE_NAME <<EOF
/^$PATTERN
-1
a
$STR_TO_ADD
.
wq
EOF