sed - Add few line with in the middle of a file -
i want add few in file. possible use sed?
original file test1 test2 test3
expected output after adding new line
test1 # testing123 # test3
if don't mind using "while/read" instead of "sed", 1 solution:
[~]$ cat original.txt test1 test2 test3 [~]$ cat new_content.txt # testing123 #
then, process both files following script:
script.sh
#!/bin/bash while ifs= read -r line if [[ $line =~ ^test2.*$ ]] cat new_content.txt else echo "$line" fi done < original.txt
Comments
Post a Comment