perl or awk, field length check

Hi Everyone,

1.txt

a;1234;134;1111111
b;123;123;1111111
c;123;1334;1111111
d;1234;1234;1111111

output

a;1234;134;1111111
c;123;1334;1111111
d;1234;1234;1111111

if field2 legth>3 or field3 length >3, then output. Please advice.

Thanks

awk -F";" 'length($2)>3 || length($3)>3' infile
1 Like

Thanks

while(<DATA>){
  print if /^[^;]*;(?=([^;]{4}|[^;]{1,3};[^;]{4}))/;
}
__DATA__
a;1234;134;1111111
b;123;123;1111111
c;123;1334;1111111
d;1234;1234;1111111
$
$ cat f6
a;1234;134;1111111
b;123;123;1111111
c;123;1334;1111111
d;1234;1234;1111111
$
$
$ perl -F';' -lane 'print if length($F[1])>3 || length($F[2])>3' f6
a;1234;134;1111111
c;123;1334;1111111
d;1234;1234;1111111
$
$

tyler_durden