Last active
November 30, 2024 09:41
-
-
Save sepastian/5a39eb7aff7adcf2ba2460ca0738664a to your computer and use it in GitHub Desktop.
Sort by German month names
This file contains hidden or 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
# Use the `sort` command to sort by German month names. | |
# | |
# E.g. sort files containing month names in ther path. | |
# make sure desired locale is installed | |
$ localectl list-locales | |
C.UTF-8 | |
en_US.UTF-8 | |
# install missing locales, if required | |
$ sudo dpkg-reconfigure locales | |
# list locales again | |
$ localectl list-locales | |
C.UTF-8 | |
de_AT.UTF-8 | |
en_US.UTF-8 | |
sv_SE.UTF-8 | |
# sample file containing german month names, in random order | |
$ cat /tmp/de.txt | |
Jänner | |
Dezember | |
Oktober | |
Juli | |
November | |
Februar | |
# sort using system's default locale (en-US.UTF-8) | |
# :/ | |
$ sort -k1,1M /tmp/de.txt | |
Dezember | |
Jänner | |
Oktober | |
Februar | |
Juli | |
November | |
# sort using german locale | |
# :) | |
$ LC_ALL=de_AT.UTF-8 sort -k1,1M /tmp/de.txt | |
Jänner | |
Februar | |
Juli | |
Oktober | |
November | |
Dezember | |
# hint: get month names for a specific locale | |
$ LC_ALL=de_AT.UTF8 locale mon | |
Jänner;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember | |
# sort output of `find`, | |
# by path component # containing german month name | |
$ find PDFs/ -type f -name '*pdf' | LC_ALL=de_AT.UTF-8 sort -t '/' -k2,2M | |
PDFs/Jänner/690vgm61.pdf | |
PDFs/Jänner/tugja990.pdf | |
PDFs/Jänner/p949ey0o.pdf | |
PDFs/februar/w83xx82k.pdf | |
PDFs/märz/bb9oiic2.pdf | |
PDFs/april/h3pfyr5v.pdf | |
: | |
PDFs/juli/3itakqxs.pdf | |
PDFs/august/gagwvr0z.pdf | |
PDFs/september/41i0sd5m.pdf | |
PDFs/oktober23/jeo67hlw.pdf | |
PDFs/dezember/pvnypol7.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment