I Have a file a.txt in the below format
1 23 50
1 25 6666666666666
1 23 34
If the third column value is greater than two digit then make it 0
New Data File
---------------
a.txt
1 23 50
1 25 0
1 23 34
Need your help regarding this
I Have a file a.txt in the below format
1 23 50
1 25 6666666666666
1 23 34
If the third column value is greater than two digit then make it 0
New Data File
---------------
a.txt
1 23 50
1 25 0
1 23 34
Need your help regarding this
awk '$3 > 99 {$3=0}'1 file
Using some posixsh (ksh, bash, dash ...)
while read a1 a2 a3 x
do
((a3<100)) && echo "$a1 $a2 $a3" && continue
echo "$a1 $a2 0"
done < a.txt
Or if file is big, then awk is better - faster.
awk '
{ if ($3>99) $3=0
print
}' a.txt
# or
awk '
$3 > 99 { $3=0 }
{ print }
' a.txt
awk '$3 > 99 {$3=0}'1 file
This Works fine .Can you please explain what is this 1
1 => Print line being read
awk '(length($3)>2){$3=0}'1 filename