> On May 11, 2018, at 7:16 PM, Daniel Frey <[email protected]> wrote:
>
> Hi all,
>
> I am trying to do something relatively simple and I've had something
> working in the past, but my brain just doesn't want to work today.
>
> I have a text file with the following (this is just a subset of about
> 2500 dates, and I don't want to edit these all by hand if I can avoid it):
>
> --- START ---
> December 2, 1994
> March 27, 1992
> June 4, 1994
> 1993
> January 11, 1992
> January 3, 1995
>
>
> March 12, 1993
> July 12, 1991
> May 17, 1991
> August 7, 1992
> December 23, 1994
> March 27, 1992
> March 1995
> --- END —
While loop in Bash? This is slower but it will do it:
while IFS=$’\n’ read -r line; do
if [ -z “$line” ]; then echo; fi
grep -o '\([0-9]\{4\}\)’ <<< “$line”
done < input_file
I would consider using a human date string parsing library in another language,
such as Python’s datetime where you can specify the formats, loop to check for
any and if nothing matches output a blank line.
Andrew