Quote:
|
Originally Posted by vgersh99
I cannot think of a way to do in sed, but I've been wrong before.
|
You could use the holdspace to determine if it is odd or even.
In the example below, I assume that if the holdspace is empty, it is an odd line. I would then substitute the empty string for a "." , swap back to the pattern space, output the value of pattern space to "oddFile" and then branch to the end of the script. For the next line, the holdspace now contains a ".", so the script executes ths second block which does the opposite (blanks out the holdspace and writes to "evenFile").
Personally, I'd stick with awk!
Code:
sed -n 'x
/^$/{
s/^/./
x
w oddFile
b theEnd
}
/./{
s/.//
x
w evenFile
}
:theEnd' inputFile