Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions

add sed
m (syntax highlighting fixup automation)
(add sed)
Line 780:
</pre>
 
=={{header|UNIX Shellsed}}==
<syntaxhighlight lang="sed">1!G
{{works with|Bourne Again SHell}}
h
$!d</syntaxhighlight>
{{out}}
<pre>
$ sed -f tac.sed file.txt
--- Will Rodgers
 
until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of
 
</pre>
 
 
=={{header|UNIX Shell}}==
<syntaxhighlight lang="bash">tac rodgers.txt</syntaxhighlight>
{{out}}
Output:
<pre>
--- Will Rodgers
Line 792 ⟶ 806:
"Diplomacy is the art of
</pre>
 
Notice that '''tac''' is '''cat''' in reverse order.
 
559

edits