Artificial intelligent assistant

I want to find out the employee who is working for past 3 years I have a data like this: 7369~SMITH~CLERK~7902~19801217~800~~20~ 7499~ALLEN~SALESMAN~7698~19810220~1600~300~30~ 7521~WARD~SALESMAN~7698~19810222~1250~500~30~ 7566~JONES~MANAGER~7839~19810402~2975~~20~ 7654~MARTIN~SALESMAN~7698~19810928~1250~1400~30~ 7698~BLAKE~MANAGER~7839~19810501~2850~~30~ 7782~CLARK~MANAGER~7839~19810609~2450~~10~ 7788~SCOTT~ANALYST~7566~19821209~3000~~20~ 7839~KING~PRESIDENT~~19811117~5000~~10~ 7844~TURNER~SALESMAN~7698~19810908~1500~0~30~ In the entry 5th filed is date of joining. Now i want to extract the year from the 5th field ?

I tried to compose awk command with date comparison. Try one of these - based on your date(1):

* BSD date

awk -F'~' '$5 <= '$(date -v-3y +%Y%m%d)'{print $2,$3}' file


* GNU (Linux) date

awk -F'~' '$5 <= '$(date -d '3 years ago' +%Y%m%d)'{print $2,$3}' file

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9cfcb6049e271edf0b12a10f768e4a5d