-2

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
Sven
  • 98,649
  • 14
  • 180
  • 226
Purres
  • 239
  • 1
  • 4
  • 18
  • Re your edit: No one "abused his power". Your question is hard to understand, so two users (which might be entirely different from those who close-voted it) downvoted it. Write better questions that are clearly topical and this won't happen. See the [help] and [How to ask better questions on Serverfault](http://meta.serverfault.com/questions/3608/how-can-i-ask-better-questions-on-server-fault) – Sven Dec 07 '14 at 09:09

1 Answers1

1

Unless I misunderstand, how about you append

cat filea >> fileb

You can do a sort afterwards, if that's what you're after.

Hyppy
  • 15,608
  • 1
  • 38
  • 59