Reputation: 1
"2017-09-04","D","0015","1","0015","08080000",60371,18923315.66
This is a sample record in my file abc from which I want to delete all records which are starting with 02 like -
"02080000"
"02100000"
Etc... ( Please consider " at this column start ) , I tried awk but its not working on my Linux -
awk -F"," '$6 != /^"02/' abc > abc_correct
Upvotes: 0
Views: 177
Reputation: 20022
You can remove lines with 02
on positions 2 and 3 with
grep -vE '^.02 abc
v
- skip lines
E
- Expressions
^
- start of line
.
- any character
Upvotes: 0
Reputation: 16997
Change !=
to !~
The two operators, ~
and !~
, perform regular expression comparisons
awk -F"," '$2 !~ /^"02/' infile >outfile
For 6th column
awk -F"," '$6 !~ /^"02/' infile >outfile
May be useful:
Comparison operators in Awk are used to compare the value of numbers or strings and they include the following:
>
– greater than<
– less than>=
– greater than or equal to<=
– less than or equal to==
– equal to!=
– not equal tosome_value ~ /regexp/
– true if some_value matches regexpsome_value !~ /regexp/
– true if some_value does not match regexp
Upvotes: 1