I have data in a file where one column is a date column which has date in the following format:
2021-05-10T18:25:00.000+0100
2021-05-14T18:25:00.000+0100
2021-05-19T18:25:00.000+0100
Expected output is:
10 MAY 2021
14 MAY 2021
19 MAY 2021
My approach which I've tried:
while -r read line
do
year=`echo $line | awk '{ print $1 }' `
month=`echo $line | awk '{ print $2 }' `
dt=`echo $line | awk '{ print $3 }' `
v=$dt"-"$month"-"$year
d=date '`$v' | dd-mm-yyyy
echo $d
done < /f/filename.txt
The GNU coreutils date
command supports the input format you have, e.g.:
date -f filename.txt +'%d %b %Y'
Output:
10 May 2021
14 May 2021
19 May 2021
Pipe it through tr a-z A-Z
if you want it in all-caps.
Note: tested with version 8.30 of GNU coreutils.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With