The content in fileA is:
Here’s the ip list.
ip: 2.2.3.4
ip: 2.2.3.5
ip: 2.2.3.6
ip: 2.2.3.7
The content is fileB is
ip: 1.2.3.4
ip: 1.2.3.5
ip: 1.2.3.6
ip: 1.2.3.7
How to use sed command or other commands in a bash script to produce a list below?
Here’s the ip list.
ip: 1.2.3.4
ip: 1.2.3.5
ip: 1.2.3.6
ip: 1.2.3.7
ip: 2.2.3.4
ip: 2.2.3.5
ip: 2.2.3.6
ip: 2.2.3.7
'cat fileA fileB' would only append fileB to fileA. If I insert a keyword into fileA first and then replace the keyword with fileB's text, all lines from fileB's text would combine into one line when being assigned to a variable.
t=$(cat fileB)
sed '/[keyword]/c\$t' fileA