Arrara
Arrara

Reputation: 173

Format in awk ran out

What is wrong in this code please?

input:

3693.06 6.1454e-01 1.6771e-02
3693.08 6.3320e-01 1.9238e-02
3693.11 6.1717e-01 1.7944e-02
3693.13 6.0574e-01 1.6216e-02
3693.15 6.3804e-01 1.9012e-02
3693.18 5.9520e-01 1.8732e-02
3693.2 6.0917e-01 1.5997e-02
3693.22 6.4455e-01 1.8686e-02
3693.25 6.0528e-01 1.9382e-02
3693.27 6.0475e-01 1.6515e-02
3693.29 5.7127e-01 1.7045e-02
3693.32 5.9784e-01 1.9205e-02

code:

for file in *iu.s; do awk '{printf("%5.1f" $1*10); print("  ",$2,"  ",$3)}' "$file" > "temp_file" && mv "temp_file" "$file"; done

an error:

not enough arguments to satisfy format string
    `%5.1f36930.6'
        ^ ran out for this one

I would like to print first column multiply by 10 for 1 decimal places and add spaces between columns. Thank you

Upvotes: 0

Views: 589

Answers (1)

Cyrus
Cyrus

Reputation: 88731

Add a ,:

printf("%5.1f",$1*10)
              ^

Upvotes: 3

Related Questions