Awk Notes: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
(New page: I love you awk Category:Computers)
 
No edit summary
Line 1: Line 1:
I love you awk
I love you awk
standard deviation with awk:
<pre>
    awk '{for(i=1;i<=NF;i++) {sum[i] += $i; sumsq[i] += ($i)^2}}
          END {for (i=1;i<=NF;i++) {
          printf "%f %f \n", sum[i]/NR, sqrt((sumsq[i]-sum[i]^2/NR)/NR)}
        }' file.dat >> aver-std.dat
</pre>
```
    awk '{for(i=1;i<=NF;i++) {sum[i] += $i; sumsq[i] += ($i)^2}}
          END {for (i=1;i<=NF;i++) {
          printf "%f %f \n", sum[i]/NR, sqrt((sumsq[i]-sum[i]^2/NR)/NR)}
        }' file.dat >> aver-std.dat
```


[[Category:Computers]]
[[Category:Computers]]

Revision as of 15:38, 2 November 2022

I love you awk

standard deviation with awk:

    awk '{for(i=1;i<=NF;i++) {sum[i] += $i; sumsq[i] += ($i)^2}} 
          END {for (i=1;i<=NF;i++) {
          printf "%f %f \n", sum[i]/NR, sqrt((sumsq[i]-sum[i]^2/NR)/NR)}
         }' file.dat >> aver-std.dat


```

   awk '{for(i=1;i<=NF;i++) {sum[i] += $i; sumsq[i] += ($i)^2}} 
         END {for (i=1;i<=NF;i++) {
         printf "%f %f \n", sum[i]/NR, sqrt((sumsq[i]-sum[i]^2/NR)/NR)}
        }' file.dat >> aver-std.dat

```