I am trying delete rows from a person.csv (below) for the condition that person who are not born in last 1 year:
Dataset1:
"Index","User Id","First Name","Last Name","Date of birth","Job Title"
"1","9E39Bfc4fdcc44e","new, Diamond","Dudley","06 Dec 1945","Photographer"
"3","32C079F2Bad7e6F","Ethan","Hanson","08 Mar 2014","Actuary"
"2","aaaaaaa, bbbbbb","Grace","Huerta","21 Jan 2023","Visual merchandiser"
So, the expected output would look like(last row got deleted as born in less than one year):
"Index","User Id","First Name","Last Name","Date of birth","Job Title"
"1","9E39Bfc4fdcc44e","new, Diamond","Dudley","06 Dec 1945","Photographer"
"3","32C079F2Bad7e6F","Ethan","Hanson","08 Mar 2014","Actuary"
I tried to use awk for this something like :
awk -F , '{print $5 ....}' person.csv > output.csv
But, couldn't figure out how to compare the each row date with (today minus 1 year).
Dataset2: Sometimes it is possible to have double quotes inside double quoted field e.g.(line1 field4):
"Index","User Id","First Name","Last Name","Date of birth","Job Title"
"1","9E39Bfc4fdcc44e","new, Diamond","Dudley (aka "dud")","03 Oct 2023","Photographer"
"3","32C079F2Bad7e6F","Ethan","Hanson","03 Dec 2022","Actuary"
"2","aaaaaaa, bbbbbb","Grace","Huerta","21 Jan 2023","Visual merchandiser"
I am open for 'sed' too if that can do this. Any help please, thanks!
29 Feb 2020
minus one year?date -d '-1 year' '+%d %b %Y'
work on your system to generate a date from 1 year ago (eg,16 Sep 2022
)? also, what doesawk --version
generate?