加入收藏 | 设为首页 | 会员中心 | 我要投稿 瑞安网 (https://www.ruian888.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Awk by Example--转载

发布时间:2021-02-06 15:24:08 所属栏目:Linux 来源:网络整理
导读:原文地址: http://www.funtoo.org/Awk_by_Example,_Part_1?ref=dzone http://www.funtoo.org/Awk_by_Example,_Part_2 http://www.funtoo.org/Awk_by_Example,_Part_3 halt7 operator11 root0 shutdown6 sync5 bin1 ....etc. username: halt uid:7 username:

function dotransfer(mybalance) {
mybalance[0,$2] -= amount
mybalance[curmonth,$3] += amount
mybalance[curmonth,$3] += amount
}

{
    curmonth=monthdigit(substr($1,4,3))
    amount=$7
#record all the categories encountered
if ( $2?!= "-" )
    globcat[$2]="yes"
if ( $3?!= "-" )
    globcat[$3]="yes"

#tally up the transaction properly
if ( $2 == "-" ) {
    if ( $3 == "-" ) {
        print "Error: inc and exp fields are both blank!"
        exit 1
    } else {
        #this is income
        doincome(balance)
        if ( $5 == "Y" )
            doincome(balance2)
    }
} else if ( $3 == "-" ) {
    #this is an expense 
    doexpense(balance)
    if ( $5 == "Y" ) 
        doexpense(balance2)
} else {
    #this is a transfer
    dotransfer(balance)
    if ( $5 == "Y" ) 
        dotransfer(balance2)
}                        

(编辑:瑞安网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读