[PLUG] Sorting Text File By Date

Galen Seitz galens at seitzassoc.com
Wed Jan 25 22:36:10 UTC 2012


Rich Shepard wrote:
>    I have a text file with dates in the common US slash-delimited format of
> m/d/Y; single digits are not prepended with zeros. The file is in reverse
> order; that is, today's date is at the top and the earliest data is at the
> bottom. For plotting, I need to reverse the line order. (There's a numeric
> value associated with each date.)
> 
>    After reading the sort man page I tried several options, but they all
> consider each portion of the date as a separate field. This means that all
> Januarys (1/) are contiguous by day and year.
> 
>    Is there a sort option that will do this but was not obvious to me? Or, is
> there another tool that will do the job?

If all you need to do is reverse the order of the lines, then the tac
command is what you need.

-- 
Galen Seitz
galens at seitzassoc.com



More information about the PLUG mailing list