sh AWK

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh AWK相关的知识,希望对你有一定的参考价值。

# if in awk
$2 > 4 { n = n + 1; pay = pay + $2 * $3 }
END {
    if (n > 0)
        print n, "employees, total pay is", pay, "average pay is", pay / n
    else
        print "no employees are paid more than $6/hour"
}

# for in awk
{
    for (i = 1; i <= $3; i = i + 1)
        printf("\t%.2f\n", $1 * (1 + $2) ^ i)
}

# while in awk
{
    i = 1
    while (i <= $3) {
        printf("\t%.2f\n", $1 * (1 + $2) ^ i)
        i = i + 1
    }
}

# array in awk
{ line[NR] = $0 }
END {
    i = NR
    while (i > 0) {
        print line[i]
        i = i - 1
    }
}

以上是关于sh AWK的主要内容,如果未能解决你的问题,请参考以下文章

sh awk meminfo

sh awk - 排除

sh SAMPLE.AWK.CODES

sh Awk没有Rundeck

sh Awk列名

sh AWK