arrays - Matching exact fields -
i have question.
i working large list data , need omit in field quantity of '0'. problem is, , see why, omitting other things contain '0'
, i.e. 100, 101
, pretty contains 0
exact value of 0
.
example table:
id name food quantity price 1 josh hotdog 1 5.00 2 josh hotdog 100 5.0 3 josh hotdog 101 5.00 4 josh hotdog 0 5.00 5 josh hotdog 1 5.00
the row omit has 'id'
number '4'
. not need rows quantity of 0
. code have used command prompt one-liner apply batch files. looks this.
perl i.bak -af\t -ne "print if $f[3] =~ "/[0]/" file.txt.
now know not work because character class randomizes '0'
. in other words saying "if" there '0' anywhere in field print it(or "unless", have "if" on 1 liner time see results).
just looking exact match of '0'
, wondering if possible method using.
change
perl i.bak -af\t -ne "print if $f[3] =~ "/[0]/" file.txt.
to
perl i.bak -af\t -ne 'print if $f[3] ne "0"' file.txt
or
perl i.bak -af\t -ne 'print if $f[3] != 0' file.txt
or
perl i.bak -af\t -ne 'print if $f[3] !~ m/^0$/' file.txt
and try again.
your $f[3] =~ /[0]/
true if $f[3]
includes character 0
.
Comments
Post a Comment