Greetings all.
I would like to use sed to join all non-blank lines together in a particular file. I was thinking I could do this by simply replacing the terminating, new-line character on every line which is not blank, but I must be missing something in my sed line:
$ sed '/^.*$/s/\n$/\t/' InputFile
The solution here needs to leave blank lines untouched as the file is setup so blank lines mark the beginning of a new block of related lines, like so:
ROUTER-1-1
Virtual-Access1 is up, line protocol is up
Hardware is Virtual Access interface
MTU 1500 bytes, BW 256 Kbit, DLY 20000 usec,
reliability 255/255, txload 5/255, rxload 4/255
Encapsulation PPP, LCP Open
Dialer0 is up, line protocol is up (spoofing)
Hardware is Unknown
Internet address is 192.168.1.1/32
MTU 1500 bytes, BW 56 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, loopback not set
Virtual-Access1 is up, line protocol is up
Hardware is Virtual Access interface
MTU 1500 bytes, BW 256 Kbit, DLY 20000 usec,
reliability 255/255, txload 5/255, rxload 4/255
Encapsulation PPP, LCP Open
Loopback0 is up, line protocol is up
Hardware is Loopback
Description: Version 1.2
Internet address is 10.0.1.1/32
MTU 1514 bytes, BW 8000000 Kbit, DLY 5000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation LOOPBACK, loopback not set
Essentially, each original line in a block will end-up as a tab-delimited field on a single line of output; Something like this:
ROUTER-1-1 Virtual-Access1 is up, line protocol is up Hardware is Virtual Access interface MTU 1500 bytes, BW 256 Kbit, DLY 20000 usec, reliability \ ...
Dialer0 is up, line protocol is up (spoofing) Hardware is Unknown Internet address is 192.168.1.1/32 MTU 1500 bytes, BW 56 Kbit, DLY 20000 usec, \ ...
Virtual-Access1 is up, line protocol is up Hardware is Virtual Access interface MTU 1500 bytes, BW 256 Kbit, DLY 20000 usec, reliability \ ...
Loopback0 is up, line protocol is up Hardware is Loopback Description: Version 1.2 Internet address is 10.0.1.1/32 MTU 1514 bytes, BW 8000000 \ ...
Please correct my misguided ways and also let me know if you have a more eligant solution to this problem.
Thanks!
--Steve
(Linux newbie...in case you couldn't tell)
p.s.
For anyone out there reading this on a small monitor, I'm sorry if my lines of example output are excessively long.
I thought about using shorter (...and more boring) lines of input, but in the end, thought it might be more interesting and instructive if I included the real-world data with which I'm working.
If I made the wrong call here, let me know and I'll refrain from including long lines in my future posts.