Linux (centos) shell inserts text content into a specified line, which can be achieved using sed or awk

#If you know the line number, you can use the following method
sed -i '88 r b.file' a.file #Insert file b.txt at line 88 of a.txt
awk '1;NR==88{system("cat b.file")}' a.file > a.file #If

you don't know the line number, you can use regular matching
sed -i '/regex/ r b.txt' a.txt # regex is a regular expression
awk '/target /{system("cat b.file")}' a.file > c.file

#sed If you do not change the source file, you can remove the -i switch, and the modification will be output to STDOUT

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326391372&siteId=291194637