Inspired by this question: sed: N command does not read single line I wanted to understand why there appears to be an inconsistency between the following 2 commands:#1. echoThis command produces no output$ echo -en 'abc\n' | sed -n 'N;p'$A hex dump of the output from echo:od - octal dump$ echo -en 'abc\n' | od -tx10000000 61 62 63 0a0000004hexdump$ echo -en 'abc\n' | hexdump -C00000000  61 62 63 0a                                       |abc.|00000004#2. catIf I put the string 'abc\n' in a file such as this:1: abc2:That's a line with the string abc on it followed by a linefeed (\n aka. 0x0A). Then pipe it to sed as before, I get this:$ cat abc.txt | sed -n 'N;p'abc$That's output that includes the string abc followed by 2 linefeeds.od - octal dump$ cat abc.txt | od -tx10000000 61 62 63 0a 0a0000005hexdump$ cat abc.txt | hexdump -C00000000  61 62 63 0a 0a                                    |abc..|00000005I'm a little perplexed as to what's going on?UPDATEOK so my issue was with how I was creating the file abc.txt as @choroba pointed out. I was creating the file in vim and not realizing that it was adding 2 linefeeds. When I enabled visibility of special characters it became a little more obvious::set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<,:set listNow in vim file abc.txt looked like this:abc$$If I created the file as @choroba suggested then the file abc.txt showed up as expected:$ cat abc.txt | od -tx10000000 61 62 63 0a0000004And it behaved identical to the original echo example:$ cat abc.txt | sed -n 'N;p'$ Original issueMy original issue with why sed -n 'N;p' wasn't displaying anything was answered thanks to @enzotib's answer. The bit from the POSIX standard is what I wasn't picking up on:If no next line of input is available, the N command verb shall branch  to the end of the script and quit without starting a new cycle or  copying the pattern space to standard output
Why the inconsistency with using cat vs. echo piped to this sed command?
scripting;sed;cat;echo;newlines
The POSIX standard states:[2addr] N Append the next line of input, less its terminating  <newline>, to the pattern space, using an embedded <newline> to  separate the appended material from the original material. Note that  the current line number changes. If no next line of input is  available, the N command verb shall branch to the end of the script  and quit without starting a new cycle or copying the pattern space to  standard output.so the behavior is very different if there is or not a next line.Your input, as you can see from the output of od -x, differ just in a newline.