Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions
Reverse the order of lines in a text file while preserving the contents of each line (view source)
Revision as of 11:03, 15 December 2022
, 1 year agoadd sed
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(add sed) |
||
Line 780:
</pre>
=={{header|
<syntaxhighlight lang="sed">1!G
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}}
<pre>
--- Will Rodgers
Line 792 ⟶ 806:
"Diplomacy is the art of
</pre>
Notice that '''tac''' is '''cat''' in reverse order.
|