0

I have a file "hosts" generated from other scripts in this format (line-by-line no spaces):

IPv4_1
hostname_1
IPv4_2
hostname_2
...

ie:

10.10.71.11
vm_1
10.66.12.12
vm_2
...

I would like to process this file line by line (with a space or tab between them) in this format:

IPv4_1 TAB/SPACE hostname_1
IPv4_2 TAB/SPACE hostname_2
...

ie:

10.10.71.11  vm_1
10.66.12.12  vm_2
...

Any help will be appreciated.

Toto
  • 86,179
  • 61
  • 85
  • 118
sf5001
  • 9
  • 2
  • 1
    Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/questions/4736) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Feb 02 '20 at 09:24
  • `s/\d+(?:\.\d+){3}\K\R/\t/` – Toto Feb 02 '20 at 10:28
  • Thank you Toto. It worked ;) but now, how can I can made your changes to the "hosts" file? – sf5001 Feb 02 '20 at 11:52

0 Answers0