0

I have lots of /etc/hosts line need to be modify.

Below is example.

original file:

1.1.1.1 A a
1.1.1.2 B b
1.1.1.3 C c
1.1.1.4 D d
1.1.1.5 E e
1.1.1.6 F f
1.1.1.7 G g

request of modify:
2.1.1.3 B b
2.1.1.54 E e
2.1.1.25 G g

Desired output:
1.1.1.1 A a
2.1.1.3 B b
1.1.1.3 C c
1.1.1.4 D d
2.1.1.54 E e
1.1.1.6 F f
2.1.1.25 G g

Try to using sed to run, but don't know how to handle more than one line in /etc/hosts. should I using for loop with sed?

  • Please add to your question (no comment): What have you searched for, and what did you find? What have you tried, and how did it fail? – Cyrus Dec 05 '22 at 12:14
  • Please don't multi-post: https://unix.stackexchange.com/q/727377/133219 – Ed Morton Dec 05 '22 at 22:30

0 Answers0