Using AWK command to skip first line and determine if a ‘/’ is in specific column which happens to be a date in a CSV file, although for my request the Date field must only be formatted as ‘YYYY-MM-DD’ no Slashes
this is what I have so far but I can’t get it to recognize the Slashes in the Date field (Column 11) in the File and treat it as invalid and print the Record out.
I am not a experienced Script script writer, Please help 🙂
awk -F \| '{if(NR > 1) {{$11~/[/]/}}}' $datadir/sys_slate_app_test.csv > "invalid_other.txt"
awk: fatal: cannot open file `/sys_slate_app_test.csv' for reading (No such file or directory)
awk -F \| '{if(NR > 1) {{$11~/^//}}}' $datadir/sys_slate_app_test.csv > "invalid_other.txt"
awk: cmd. line:1: {if(NR > 1) {{$11~/^//}}}
awk: cmd. line:1: ^ syntax error
data:
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022/08/23"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022/09/10"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022-08-23"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022-06-11"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022/08/23"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"
>Solution :
You did’t show the expected output in your question so I don’t know if this is correct or not but it implements what you described best I can tell:
$ awk -F'|' '(NR > 1) && ($11 ~ "/")' file
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022/09/10"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"
"30"|"958433018"|"999999999"|"11111111"|"202340"|""|"222222222"|"Tyler"|"Ward"|"email328@yahoo.com"|"2022/08/23"|"UG"|"TR"|"0"|"0"|"0"|"2"|"1"|"RD"|"0"|"1"|"2023-03-09"