Use awk to print first 6 characters

Hi,
i want to use awk to print the first 6 characters of a variable

awk -F"|" '$3>0 { print $3 }' z00.unl > z001.unl

but $3= 7 digits
and i just want to print the first 6 digits.

eg 1005779 but i want to print only 100577

$ cat file1
abc|ABC|123456789|QWERTZ
abc|ABC|1|QWERTZ
abc|ABC|0|QWERTZ
abc|ABC|123456789|QWERTZ

$ awk -F\| '$3 > 0 { print substr($3,1,6)}' file1
123456
1
123456

1 Like
awk -F"|" '$3>0 { print substr($3,1,6)}'
1 Like

thanks the awk worked