Insert content of a file to another file on Linux -
i have 2 files. want insert content of first file(file1
) second file (file2
) between codes (second file script). example second file should this
upcode... #upcode ends here file1 content downcode ...
upcode #upcode ends here
, downcode should never change.
how can done?
here script (note start tag has unique in file)--
#!/bin/bash start="what need" touch file2.tmp while read line if [ "$line" = "$start" ] echo "$line" >> file2.tmp cat file2 >> file2.tmp fi echo "$line" >> file2.tmp done < file1 #mv file2.tmp file1 -- moves (i.e. renames) file2.tmp file1.
Comments
Post a Comment