将while循环记录传递给函数

问题描述 投票:0回答:1

我如何传递参数以在Linux中运行。我正在文件中一行一行地变红并在后台运行esch记录

while read -r record
    do
        reccount=$(( reccount + 1 ))
        #function call  
        proceed_tasks_function(record) &
done

到功能

proceed_tasks_function(/*take the record from function call*/)
{
### parse input record

          contact_email=`echo "$record" | cut -f5 -d ''`
              echo "contact email is $contact_email" 
          credit_card_id=`echo "$record" | cut -f6 -d ''`
              echo "credit card id is $credit_card_id"
          ref_nr=`echo "$record" | cut -f7 -d ''`
              echo "reference nr is $ref_nr"
          cny_cd=`echo "$record" | cut -f8 -d ''`
              echo "country code is $cny_cd"
          lang=`echo "$record" | cut -f9 -d ''`
              echo "language is $lang"
          pmt_ir=`echo "$record" | cut -f13 -d ''`
              echo "payment ir is $pmt_ir"
}
linux bash shell sh ksh
1个回答
0
投票

shell中的函数与其他任何命令一样:参数仅在命令后列出,不需要或不允许使用括号。

while read -r record
    do
        reccount=$(( reccount + 1 ))
        proceed_tasks_function "$record" &
done
© www.soinside.com 2019 - 2024. All rights reserved.