批量更新shell脚本(post请求)

function deviceRecover12(){
            for line in `cat device.txt`
               do
                var=$(curl -s -H 'content-type: application/json' -H "o::90EBC43BE0BC4B64998A55B285B01965" -X POST -d '{"deviceName": "'$line'", "ctrlType": "17"}' https://xxxxxx)
                echo "device:$line,status:$var"
           done
}

device.txt

001050101021000000001
001050101021000000002
001050101021000000003
001050101021000000004
001050101021000000005
001050101021000000006
001050101021000000007
001050101021000000008

1.新建test.sh 的shell文件,文件内容就是上述第一个脚本内容

2.如何执行包含函数的shell脚本?  第一:source  test.sh  第二步:直接输入函数名  deviceRecover12

3.假如shell脚本函数有参数输入的话,就是在函数体内,输入$1(代表第一个参数),$2(代表第二个参数)

在执行有输入参数的函数时: 函数名   第一个参数   第二个参数

原文地址:https://www.cnblogs.com/zhangshitong/p/13755893.html