Reverse order of lines in a text file
revlines.cpp
 
Revlines is a program I wrote to do a text processing operation I often want to do but for which I've never found a good tool.
 
Basically, what it does is read all the lines in a text file and reverse them, that is all the lines rotate around the middle. The first line becomes the last, the last becomes the first, and all the others behave similarly. I find it useful in writing ordered lists. Sometimes I might save a program trace that shows all the functions called in time order but I actually want to see them in the reverse order - I want to see the most recently executed function at the top. I found I was running into this situation a lot, particularly in debugging, and I wanted an easy way to reverse the lines.
 
This program also served three other purposes for me.
 
  1. It served as a C++ learning exercise even though I defined no objects within it.
  2. It also served to give me some experience with the C++ standard library.
  3. Unlike my other text filter programs this program is completely self-contained. It contains the same filter framework that is used in the C language filters, ported to C++. As I write more filters in C++ I'll abstract the filter framework from this file and put it, like the C versions, into separate modules shared by all C++ filters.
 
The following information can also be seen by typing revlines -h
 
Usage: revlines [-h] [--help] [--version] [files ...]
Reverse order of lines in a file
 
Options:
  --version display version information
  -h        display this message (and version information)
  --help
Previous  |  Next ]     [ Up  |  First  |  Last ]     (Article 12 of 485)
 
Comments, flames, broken links?
Please send email to maintainer@intricate-simplicity.com