Insert Word After Match

Dear ALL,

I have sample file :

host.txt

fullname: FreeBSD
Host: server1
ip: 1.1.1.1
mask: 255.255.255.0

fullname: CentOS
Host: server2
mask: 255.255.255.0

fullname: Fedora
Host: server3
ip: 1.3.1.2
mask: 255.255.255.0

fullname: Asterisk
Host: VoIP1
ip: 1.1.2.4
mask: 255.255.255.0

required output:

fullname: FreeBSD
Host: server1
ip: 1.1.1.1
mask: 255.255.255.0

fullname: CentOS
Host: server2
ip: no-ip
mask: 255.255.255.0

fullname: Fedora
Host: server3
ip: 1.3.1.2
mask: 255.255.255.0

fullname: Asterisk
Host: VoIP1
ip: 1.1.2.4
mask: 255.255.255.0

Can you help me pls..

Thanks

Your repeated refusal to properly format your posts has resulted in this account being placed in read-only mode again. (This time for two weeks.) Future posts that are improperly formatted may result in you being permanently banned from using this site.

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

1 Like

Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework Questions forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

If this is not a homework assignment, please explain:

  1. why you need to do this,
  2. what operating system you're using,
  3. what shell you're using, and
  4. show us what you have tried to do to solve this problem on your own.

We want to help you learn how to do things like this on your own, but we are not here to act as your unpaid programming staff and we are not here to do your homework assignments for you.

1 Like