I have a pipe delimited file as below.
data.txt
ESP|041336|46566|NY|CA
ESP|041337|46566|NY|CA
ESP|041338|46566|NY|CA
ESP|041339|46566|NY|CA
ESP|041340|46566|NY|CA
ESP|041341|46566|NY|CA
I have another file with values in the second column that needs to be removed.
Input.txt
041337
041338
041339
I am trying to remove rows that have values from input.txt in its second column.
Expected Output
ESP|041336|46566|NY|CA
ESP|041340|46566|NY|CA
ESP|041341|46566|NY|CA
I am trying to use grep here as below to achieve this.
grep -vfw input.txt data.txt > output.txt
This doesn't remove the columns but throws an error No such file or directory and returns an empty file.