Quote:
Originally Posted by gosha
...I want to take away the redundant "1" and "2" simply because it becomes more readable (at least for me).
|
Understandable, but depending upon how far you want to remove redundancy, you may be needing to buffer
many rows
(at least the number of columns you are outputting...), & the logic will grow with the sophistication. Nevertheless, that is a decision you will need to make. It all depends upon whether the result is worth your time & effort.
Yet going back to your original question, I don't see that you will be able to do this kind of formatting in
sed(1). The point being is that you are on a slippery slope of formatting wants & desires which will ultimately force you to resort to
awk(1),
perl(1),
etc. soon, so you might as well be finding something more powerful than
sed(1) now.
If you are reticent to move to a different tool due to unfamiliarity, google for
"xyz tutorial", & you should be able to find enough to get started. This is particularly true of awk, & as I recall, there are some reasonable tutorials over at IBM's DeveloperWorks site
(where ironically, there are tutorials for sed as well... ).