Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions
Content added Content deleted
(add OCaml) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 797: | Line 797: | ||
</pre> |
</pre> |
||
=={{header|Ruby}}== |
|||
<syntaxhighlight lang="ruby">puts File.readlines("diplomacy.txt").reverse</syntaxhighlight> |
|||
{{out}} |
|||
<pre> --- Will Rodgers |
|||
until you can find a rock." |
|||
saying 'Nice Doggy' |
|||
"Diplomacy is the art of |
|||
</pre> |
|||
=={{header|sed}}== |
=={{header|sed}}== |
||
<syntaxhighlight lang="sed">1!G |
<syntaxhighlight lang="sed">1!G |
||
Line 811: | Line 820: | ||
</pre> |
</pre> |
||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |