Can someone explain why this is happening?
Expected:
$ echo -e "foo\nbar" | sed -n 'h; x; p' foo bar
I put each line in the hold space, then I change the place to hold and the picture space, and then print the pattern space so that each line is printed. Now, why are the following different?
$ echo -e "foo\nbar" | sed -n 'h; d; x; p'
I thought that this would not happen, because I am deleting the template space before replacing it, so the saved string should be returned back to the template space. This is the hold space that should be empty after x;
, right? I delete the template space,, then . Where is the line that I saved?
source share