Need help for awk command

Hi

I have a column which contains values like
000000000035.25600

I want the output as

00000000000035.256
 
i.e Two zero'z should be appended at the beginning and removed from the end

Could you please help me with a command for this. I want to modify all the records for this column in the file. The column number is 10th column in the file

Do all values in 10th column contain exactly 2 zeroes at the end?

Yes all values contain two zero's at the end

Try:

printf "%018.3f\n"

How to apply that command to the tenth column in a file

Try:

$10=sprintf("%018.3f",$10)

By using Scrutinizer's format in a awk command like:

awk '{$10=sprintf("%018.3f",$10)}1' infile

That assumes that the columns are space separated.

Edit: Ooops. Scrutinizer is lightning fast and gets up early on a saterday morning :slight_smile:

1 Like

I tried this command

awk -F"�" '{ $10=sprintf ("%018.3f",$10); print}' OFS=\� CC_TRANSACTION_SETTLEMENT_20120510.dat
 

But now the porblem is the data i am getting is correct but its also replacing the 10th column name which is "amount" to 00000000000000.000

So is there a way i can skip the header and apply that command on the records.
The header is the first row. And the actual data starts from the second row

Just ask awk to skip line one with:

awk 'NR>1{...}'

And if you need the header:

awk 'NR>1{...}NR==1{print}'