Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions
Content added Content deleted
(Added Python implementation) |
Catskill549 (talk | contribs) (added AWK) |
||
Line 97: | Line 97: | ||
saying 'Nice Doggy' |
saying 'Nice Doggy' |
||
"Diplomacy is the art of |
"Diplomacy is the art of |
||
</pre> |
|||
=={{header|AWK}}== |
|||
<lang AWK> |
|||
# syntax: GAWK -f REVERSE_THE_ORDER_OF_LINES_IN_A_TEXT_FILE_WHILE_PRESERVING_THE_CONTENTS_OF_EACH_LINE.AWK filename |
|||
{ arr[NR] = $0 } |
|||
END { |
|||
for (i=NR; i>=1; i--) { |
|||
printf("%s\n",arr[i]) |
|||
} |
|||
exit(0) |
|||
} |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
--- Will Rodgers |
|||
until you can find a rock." |
|||
saying 'Nice Doggy' |
|||
"Diplomacy is the art of |
|||
</pre> |
</pre> |
||