DATESORT(1)
π DATESORT(1) β the datesort page π
ok so this is datesort, from the User Commands section of the manual, and bestieβ¦ it sorts your files by when things happened, not by boring alphabet things. iconic behavior honestly π
β¨ NAME β¨
datesort β sort the contents of FILE chronologically π°οΈ
πΈ SYNOPSIS πΈ
datesort [OPTION]... [FILE]...
π DESCRIPTION π
It sorts the contents of FILE chronologically. And if you justβ¦ don't give it a FILE? No stress, it reads from stdin like a good little program π«Ά
The first date/time value on each line is the sort key, periodt. That's the whole vibe.
Now here's the hierarchy, and yes it matters:
- Dates without times count as a smaller value than any date/time on that same day.
- Times without dates count as a smaller value than any date or date/time.
- And if a line has no dates or times or date/times in it at all? It gets sorted towards the front. main character line, zero timestamps π
β¨ Recognized OPTIONs β¨
-h,--helpβ print help and dip out-V,--versionβ print the version and dip out-i,--input-format=STRING...β the input format, and ngl you can pass this multiple times. Each date/time gets handed to the input format parsers in the order you gave them, and if a date/time can be read successfully with a given input format specifier string, that value gets used. first one to slay wins π-b,--base=DTβ for underspecified input, use DT as a fallback to fill in the missing fields. It's also used for ambiguous format specifiers, to position their range on the absolute time line. It must be a date/time in ISO8601 format. If you omit it, it defaults to the current date/time β°-e,--backslash-escapesβ turn on interpretation of backslash escapes in the input format specifier strings π¦--from-locale=LOCALEβ interpret dates on stdin or the command line as coming from the locale LOCALE. Heads up: this would only affect month and weekday names, since input formats have to be specified explicitly π--from-zone=ZONEβ interpret dates on stdin or the command line as coming from the time zone ZONE π-r,--reverseβ reverse the sort order. flip it and reverse it π-u,--uniqueβ print at most one line per date/time value. no duplicates, we don't do that here π
π§ FORMAT SPECS π§
So the format specs in dateutils are similar to posix' strftime().
However β and this is the tea β β because dateutils supports a broader range of calendars, it has to employ different rules. so don't come for it.
π Date specs π
%aβ the abbreviated weekday name%Aβ the full weekday name%_aβ the weekday name shortened to a single character (MTWRFAS)%bβ the abbreviated month name%Bβ the full month name%_bβ the month name shortened to a single character (FGHJKMNQUVXZ)%cβ the count of the weekday within the month (range 00 to 05)%Cβ the count of the weekday within the year (range 00 to 53)%dβ the day of the month, 2 digits (range 00 to 31)%Dβ the day of the year, 3 digits (range 000 to 366)%Fβ equivalent to%Y-%m-%d(ymd's canonical format) π%gβ ISO week date year without the century (range 00 to 99)%Gβ ISO week date year including the century%jβ equivalent to%D%mβ the month in the current calendar (range 00 to 12)%Qβ the quarter of the year (range Q1 to Q4)%qβ the number of the quarter (range 01 to 04)%sβ the number of seconds since the Epoch.%uβ the weekday as number (range 01 to 07, Sunday being 07)%Uβ the week count, day of week is Sun (range 00 to 53)%Vβ the ISO week count, day of week is Mon (range 01 to 53)%wβ the weekday as number (range 00 to 06, Sunday being 00)%Wβ the week count, day of week is Mon (range 00 to 53)%yβ the year without a century (range 00 to 99)%Yβ the year including the century%_yβ the year shortened to a single digit%Zβ the zone offset in hours and minutes (HH:MM), with a preceding sign (+for offsets east of UTC,-for offsets west of UTC)
and the roman numeral girlies ποΈ:
%Odβ the day as roman numerals%Omβ the month as roman numerals%Oyβ the two digit year as roman numerals%OYβ the year including the century as roman numerals
and the calendar-specific ones:
%rsβ in time systems whose Epoch is different from the unix Epoch, this selects the number of seconds since then.%rYβ in calendars with years that don't coincide with the Gregorian years, this selects the calendar's year.
and the ordinal/business-day cuties π:
%dthβ the day of the month as an ordinal number, 1st, 2nd, 3rd, etc.%mthβ the month of the year as an ordinal number, 1st, 2nd, 3rd, etc.%dbβ the business day of the month (since last month's ultimo)%dBβ number of business days until this month's ultimo
π¦ Time specs π¦
%Hβ the hour of the day using a 24h clock, 2 digits (range 00 to 23)%Iβ the hour of the day using a 12h clock, 2 digits (range 01 to 12)%Mβ the minute (range 00 to 59)%Nβ the nanoseconds (range 000000000 to 999999999)%pβ the stringAMorPM, noon is PM and midnight is AM.%Pβ like%pbut in lowercase%Sβ The (range 00 to 60, 60 is for leap seconds)%Tβ equivalent to%H:%M:%S
nope, there is genuinely a missing word in the original %S line. we're reporting it exactly as found, not inventing a description, bestie π (60 is for leap seconds though, slay)
π General specs π
%nβ a newline character%tβ a tab character%%β a literal%character
β Modifiers β
%Oβ modifier to turn decimal numbers into Roman numerals%rβ modifier to turn units into real units%0β modifier to turn on zero prefixes%SPCβ modifier to turn on space prefixes%-β modifier to turn off prefixes altogetherthβ suffix, read and print ordinal numbersbβ suffix, treat days as business days
π¨ real talk: by design, dates before 1601-01-01 are not supported. don't try it. it's not going to work and it's not going to be cute.
π Calendar designators π
For conformity, here's a list of calendar designators and their corresponding format string:
ymdβ%Y-%m-%dymcwβ%Y-%m-%c-%wywdβ%rY-W%V-%ubizdaβ%Y-%m-%dblilianβ n/aldnβ n/ajulianβ n/ajdnβ n/amatlabβ n/amdnβ n/a
These designators can be used as output format string, moreover, @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used as input format string. iykyk π§
π₯ EXAMPLES π₯
bestie just look at them go:
$ dsort < "$@{srcdir@}/caev_01.txt"
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
$
$ dsort "$@{srcdir@}/caev_01.txt"
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
$
$ dsort -r < "$@{srcdir@}/caev_01.txt"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
$
$ dsort -r "$@{srcdir@}/caev_01.txt"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
$
$ dsort -u < "$@{srcdir@}/caev_02.txt"
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
2010-11-17 caev="XXXX" secu="VOD" exch="XLON" xdte="2010-11-17"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
$
$ dsort -u "$@{srcdir@}/caev_02.txt"
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
2010-11-17 caev="XXXX" secu="VOD" exch="XLON" xdte="2010-11-17"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
$
π«Ά AUTHOR π«Ά
Written by Sebastian Freundt <freundt@fresse.org> β ty for your service king π
π REPORTING BUGS π
Report bugs to: https://github.com/hroptatyr/dateutils/issues
(be nice about it, they're doing their best π₯Ί)
π SEE ALSO π
The full documentation for datesort is maintained as a Texinfo manual. And if the info and datesort programs are properly installed at your site, this command:
info (dateutils)datesort
should give you access to the complete manual. go read it, it's giving lore πβ¨
and that's the whole page bestie!! π
this is dateutils 0.4.11, dated January 2024 β go sort something chronologically and think of me π¦ππ
π¦ where this page comes from
- alpine 3.24: dateutils-doc 0.4.11-r0 Β· BSD-3-Clause
- nixos 26.05: dateutils 0.4.11
- nixpkgs unstable: dateutils 0.4.11
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- opensuse-leap 16.0: dateutils 0.4.11-bp160.1.17 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms