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 00:18, 11 October 2021
, 2 years agoadded AWK
(Added Python implementation) |
Catskill549 (talk | contribs) (added AWK) |
||
Line 97:
saying 'Nice Doggy'
"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>
|