Replace all values in one column to 1

awkgrepreplacesedtext processing

I have multiple text files containing 12 lines and 3 columns.

Example:

2       6    0.74  
42      6    0.58  
80      6    0  
112     6    0.24  
132     6    1  
216     6    0.7  
342     6    0  
390     6    0.21  
432     6    0.56  
466     6    0.75  
524     6    0.6  
646     6    0.9 

I want to set all the values of the third column to 1 in all lines.

The output should look like this :

2    6   1  
42   6   1  
80   6   1  
112  6   1  
132  6   1  
216  6   1  
342  6   1  
390  6   1  
432  6   1  
466  6   1  
524  6   1  
646  6   1  

Does anyone know a command that can solve this problem?

Best Answer

awk '{print $1, $2, "1"}' inputfile
Related Question