Skip to content

Instantly share code, notes, and snippets.

@FernandoBasso
Created March 14, 2016 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoBasso/d211232fe215f175c3b5 to your computer and use it in GitHub Desktop.
Save FernandoBasso/d211232fe215f175c3b5 to your computer and use it in GitHub Desktop.
Trying to understand how "reverse lines" in sed works
file:
AA
BB
CC
DD
sed command:
sed -n '1! G; h; $ p'
step/cmd PS HS STDOUT
-------------------------------------------------------------------
IL1 AA AA ␀
h AA AA
IL2 BB BB AA
G BB\nAA AA
h BB\nAA BB\nAA
IL3 CC CC BB\nAA
G CC\nBB\nAA BB\nAA
h CC\nBB\nAA CC\nBB\nAA
IL4 DD DD CC\nBB\nAA
G DD\nCC\nBB\nAA CC\nBB\nAA
h DD\nCC\nBB\nAA DD\nCC\nBB\nAA
p DD\nCC\nBB\nAA DD\nCC\nBB\nAA DD\nCC\nBB\nAA
----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment