Este snippet:
# Utility functions: print-as-echo, print-line-with-visual-space.
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
pl " Input data file $FILE:"
head data1
# start="10/29/2017" end="11/2/2017"
START="10/29/2017"
END="11/2/2017"
pl " Results, from $START through $END:"
dateutils.dgrep -i "%m/%d/%Y" ">=$START" '&&' "<=$END" < data1
pl " Unsorted file, data2:"
head data2
pl " Results, from $START through $END, randomly organized file:"
dateutils.dgrep -i "%m/%d/%Y" ">=$START" '&&' "<=$END" < data2
produz:
-----
Input data file :
1,10/22/2017,Scheduled
2,10/23/2017,Confimred
1,10/24/2017,NA
1,10/29/2017,Scheduled
3,11/1/2017,Scheduled
1,11/2/2017,Scheduled
-----
Results, from 10/29/2017 through 11/2/2017:
1,10/29/2017,Scheduled
3,11/1/2017,Scheduled
1,11/2/2017,Scheduled
-----
Unsorted file, data2:
1,10/22/2017,Scheduled
1,10/24/2017,NA
1,10/29/2017,Scheduled
1,11/2/2017,Scheduled
2,10/23/2017,Confimred
3,11/1/2017,Scheduled
-----
Results, from 10/29/2017 through 11/2/2017, randomly organized file:
1,10/29/2017,Scheduled
1,11/2/2017,Scheduled
3,11/1/2017,Scheduled
em um sistema como:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution : Debian 8.9 (jessie)
bash GNU bash 4.3.30
Como a comparação é aritmética em dados formatados por data, os dados podem estar em qualquer ordem. O resultado final pode ser classificado, se desejado - veja sort, msort, dsort.
Os códigos de datasutils estão disponíveis em muitos repositórios e no OSX (via brew).
Alguns detalhes para dateutils.dgrep:
dateutils.dgrep Grep standard input for lines that match EXPRESSION. (man)
Path : /usr/bin/dateutils.dgrep
Package : dateutils
Home : http://www.fresse.org/dateutils
Version : 0.3.1
Type : ELF64-bitLSBsharedobject,x86-64,version1(S ...)
Help : probably available with -h,--help
Home : https://github.com/hroptatyr/dateutils (doc)
Felicidades ... felicidades, drl