With a simple bash script I generate a text file with many lines like this:
192.168.1.1
hostname1
192.168.1.2
hostname2
192.168.1.3
hostname3
Now I want to reformat this file so it looks like this:
192.168.1.1 hostname1
192.168.1.2 hostname2
192.168.1.3 hostname3
How would I reformat it this way? Perhaps sed
?
$ sed '$!N;s/\n/ /' infile
192.168.1.1 hostname1
192.168.1.2 hostname2
192.168.1.3 hostname3