You can use the following awk:
awk -F, '{ $4 = ($4 == "N/A" ? -1 : $4) } 1' OFS=, test.csv
- We set the input and output field separators in
,to save the separators in your csv file - We check the fourth field, if it is equal to "N / A", then we assign a value to it
-1, if we do not store the value as is. 1 4- , .($4=="N/A"?-1:$4) - , , $4=="N/A" . true ?, -1, false :, .
:
$ cat file
a,b,c,d,e,f
1,2,3,4,5,6
44,2,1,N/A,4,5
24,sdf,sdf,4,2,254,5
a,f,f,N/A,f,4
$ awk -F, '{ $4 = ($4 == "N/A" ? -1 : $4) } 1' OFS=, file
a,b,c,d,e,f
1,2,3,4,5,6
44,2,1,-1,4,5
24,sdf,sdf,4,2,254,5
a,f,f,-1,f,4