Created
September 2, 2012 15:59
-
-
Save kirichkov/3600875 to your computer and use it in GitHub Desktop.
Reverse a text file's lines - the first line becoming the last
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat -n FILE | sort -nr | cut -c 8- > NEWFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reverses FILE's content, making the last line to become the first. Each line's content is not modified, just the line's position.
Tweek the cut -c X to get proper results on different OSs.
This script is tested on MacOS X and with files with less than 100 lines