Here is my sed command:
echo -e "AB\nCD\nEF\nGH" | sed 'N; D;'
It prints:
GH
while sed
processing input line by line, what happens with the last line? (When after that sed
saw End-Of-File)? I mean the pattern buffer only contains 1 line.
sedtext processing
Here is my sed command:
echo -e "AB\nCD\nEF\nGH" | sed 'N; D;'
It prints:
GH
while sed
processing input line by line, what happens with the last line? (When after that sed
saw End-Of-File)? I mean the pattern buffer only contains 1 line.
Best Answer
It halts processing. From the sed manual:
N
: Add a newline to the pattern space, then append the next line of input to the pattern space. If there is no more input then sed exits without processing any more commands.So it never gets to the
D;
, and you're left with just the lastGH
.