0

how can i pass parameter to function in linux. I am reding line by line in a file and run the esch record in background

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

to the function

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"
}

1 Answers1

0

A function in shell is like any other command: arguments are simply listed after the command, no parentheses needed or allowed.

while read -r record
    do
        reccount=$(( reccount + 1 ))
        proceed_tasks_function "$record" &
done
chepner
  • 497,756
  • 71
  • 530
  • 681