1DATESORT(1) User Commands DATESORT(1)
2
3
4
6 datesort - Sort contents of FILE chronologically.
7
9 datesort [OPTION]... [FILE]...
10
12 Sort contents of FILE chronologically. If FILE is omitted read from
13 stdin.
14
15 The first date/time value per line is the sort key. Dates without
16 times account for a smaller value than any date/time on the same day.
17 Times without dates account for a smaller value than any date or
18 date/time. If a line contains no dates or times or date/times it is
19 sorted towards the front.
20
21
22 Recognized OPTIONs:
23
24 -h, --help
25 Print help and exit
26
27 -V, --version
28 Print version and exit
29
30 -i, --input-format=STRING...
31 Input format, can be used multiple times. Each date/time will
32 be passed to the input format parsers in the order they are
33 given, if a date/time can be read successfully with a given
34 input format specifier string, that value will be used.
35
36 -b, --base=DT
37 For underspecified input use DT as a fallback to fill in missing
38 fields. Also used for ambiguous format specifiers to position
39 their range on the absolute time line. Must be a date/time in
40 ISO8601 format. If omitted defaults to the current date/time.
41
42 -e, --backslash-escapes
43 Enable interpretation of backslash escapes in the input format
44 specifier strings.
45
46 --from-locale=LOCALE
47 Interpret dates on stdin or the command line as coming from the
48 locale LOCALE, this would only affect month and weekday names as
49 input formats have to be specified explicitly.
50
51 --from-zone=ZONE
52 Interpret dates on stdin or the command line as coming from the
53 time zone ZONE.
54
55 -r, --reverse
56 Reverse the sort order.
57
58 -u, --unique
59 Print at most one line per date/time value.
60
62 Format specs in dateutils are similar to posix' strftime().
63
64 However, due to a broader range of supported calendars dateutils must
65 employ different rules.
66
67 Date specs:
68 %a The abbreviated weekday name
69 %A The full weekday name
70 %_a The weekday name shortened to a single character (MTWRFAS)
71 %b The abbreviated month name
72 %B The full month name
73 %_b The month name shortened to a single character (FGHJKMNQUVXZ)
74 %c The count of the weekday within the month (range 00 to 05)
75 %C The count of the weekday within the year (range 00 to 53)
76 %d The day of the month, 2 digits (range 00 to 31)
77 %D The day of the year, 3 digits (range 000 to 366)
78 %F Equivalent to %Y-%m-%d (ymd's canonical format)
79 %g ISO week date year without the century (range 00 to 99)
80 %G ISO week date year including the century
81 %j Equivalent to %D
82 %m The month in the current calendar (range 00 to 19)
83 %Q The quarter of the year (range Q1 to Q4)
84 %q The number of the quarter (range 01 to 04)
85 %s The number of seconds since the Epoch.
86 %u The weekday as number (range 01 to 07, Sunday being 07)
87 %U The week count, day of week is Sun (range 00 to 53)
88 %V The ISO week count, day of week is Mon (range 01 to 53)
89 %w The weekday as number (range 00 to 06, Sunday being 00)
90 %W The week count, day of week is Mon (range 00 to 53)
91 %y The year without a century (range 00 to 99)
92 %Y The year including the century
93 %_y The year shortened to a single digit
94 %Z The zone offset in hours and minutes (HH:MM) with
95 a preceding sign (+ for offsets east of UTC, - for offsets
96 west of UTC)
97
98 %Od The day as roman numerals
99 %Om The month as roman numerals
100 %Oy The two digit year as roman numerals
101 %OY The year including the century as roman numerals
102
103 %rs In time systems whose Epoch is different from the unix Epoch, this
104 selects the number of seconds since then.
105 %rY In calendars with years that don't coincide with the Gregorian
106 years, this selects the calendar's year.
107
108 %dth The day of the month as an ordinal number, 1st, 2nd, 3rd, etc.
109 %mth The month of the year as an ordinal number, 1st, 2nd, 3rd, etc.
110
111 %db The business day of the month (since last month's ultimo)
112 %dB Number of business days until this month's ultimo
113
114 Time specs:
115 %H The hour of the day using a 24h clock, 2 digits (range 00 to 23)
116 %I The hour of the day using a 12h clock, 2 digits (range 01 to 12)
117 %M The minute (range 00 to 59)
118 %N The nanoseconds (range 000000000 to 999999999)
119 %p The string AM or PM, noon is PM and midnight is AM.
120 %P Like %p but in lowercase
121 %S The (range 00 to 60, 60 is for leap seconds)
122 %T Equivalent to %H:%M:%S
123
124 General specs:
125 %n A newline character
126 %t A tab character
127 %% A literal % character
128
129 Modifiers:
130 %O Modifier to turn decimal numbers into Roman numerals
131 %r Modifier to turn units into real units
132 %0 Modifier to turn on zero prefixes
133 %SPC Modifier to turn on space prefixes
134 %- Modifier to turn off prefixes altogether
135 th Suffix, read and print ordinal numbers
136 b Suffix, treat days as business days
137
138 By design dates before 1601-01-01 are not supported.
139
140 For conformity here is a list of calendar designators and their correā
141 sponding format string:
142 ymd %Y-%m-%d
143 ymcw %Y-%m-%c-%w
144 ywd %rY-W%V-%u
145 bizda %Y-%m-%db
146 lilian n/a
147 ldn n/a
148 julian n/a
149 jdn n/a
150 matlab n/a
151 mdn n/a
152
153 These designators can be used as output format string, moreover,
154 @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used
155 as input format string.
156
157
159 $ datesort < "$@{srcdir@}/caev_01.txt"
160 2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
161 2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
162 2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
163 2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
164 2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
165 2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
166 $
167
168 $ datesort "$@{srcdir@}/caev_01.txt"
169 2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
170 2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
171 2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
172 2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
173 2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
174 2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
175 $
176
177 $ datesort -r < "$@{srcdir@}/caev_01.txt"
178 2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
179 2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
180 2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
181 2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
182 2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
183 2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
184 $
185
186 $ datesort -r "$@{srcdir@}/caev_01.txt"
187 2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
188 2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
189 2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
190 2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
191 2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
192 2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
193 $
194
195 $ datesort -u < "$@{srcdir@}/caev_02.txt"
196 2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
197 2010-11-17 caev="XXXX" secu="VOD" exch="XLON" xdte="2010-11-17"
198 2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
199 2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
200 2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
201 2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
202 $
203
204 $ datesort -u "$@{srcdir@}/caev_02.txt"
205 2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
206 2010-11-17 caev="XXXX" secu="VOD" exch="XLON" xdte="2010-11-17"
207 2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
208 2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
209 2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
210 2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
211 $
212
214 Written by Sebastian Freundt <freundt@fresse.org>
215
217 Report bugs to: https://github.com/hroptatyr/dateutils/issues
218
220 The full documentation for datesort is maintained as a Texinfo manual.
221 If the info and datesort programs are properly installed at your site,
222 the command
223
224 info (dateutils)datesort
225
226 should give you access to the complete manual.
227
228
229
230dateutils 0.4.7 February 2020 DATESORT(1)