Hi, i need help on replacing negative values in a column with 0. any quick fix on this? thanks much. for instance,
input:
1
2.3
-0.4
-25
12
13
45
-12
desired output
1
2.3
0
0
12
13
45
0
Hi, i need help on replacing negative values in a column with 0. any quick fix on this? thanks much. for instance,
input:
1
2.3
-0.4
-25
12
13
45
-12
desired output
1
2.3
0
0
12
13
45
0
awk '$0+0<0{$0=0}1' inputfile
or
sed 's/^-.*/0/' inputfile
thanks much for these one-liners,
awk -F- '{$0=$1+0}1' infile
awk '$1<0{$0=0}1' input.txt
perl -lane 'if($_<0){print "0"}else{print $_}' input.txt