1.从文件按行读取,内容为逗号分隔。获取分隔后的值,同时发送http请求到指定服务上
文件内容如下:
1966389832037503488,京A99999,0 1966389822910681600,京A9B989,0 2038446222943490304,京AA7777,1 2110503816981418240,京AA7777,2 2254619005057274112,京AA7777,4 2110503808110366208,京AAA111,2 2254618996186222080,京AAA111,4 1966388620034526976,京AAA123,0 1966388619977441408,京AAAAAA,0 1966388619979538560,京AAABAA,0 2182561403471597184,京AAFS12,3 2110503849447312795,京AB00000,2 1966388654404719104,京ABA609,0 1966388654931137024,京ABC129,0 2038446248969064960,京ABC129,1 1966388654945422080,京ABC8EV,0 1966388661105249920,京ABZ182,0 1966388688701112704,京ACACAC,0 1966388689561423488,京ACD232,0 1966388689561456256,京ACD252,0 2110503918168920099,京AD01258,2 2326676700282703907,京AD01258,5 1966388765262336128,京AE3346,0
2.文件大概有7600条记录,每次读取20行,则休眠2秒。之后再处理文本。
#!/bin/sh i=0 name=(蓝 黄 绿 黄绿 黑 白) cat plates.txt | while read line do #echo $line IFS="," arr=($line) color=${arr[2]} echo "$color" plateColor=${name[$color]} param="carId=${arr[0]}&plateNumber=${arr[1]}&plateColor=$plateColor" echo $param curl -X PUT -d "$param" "http://10.168.1.2:8210/plate/plateNumber/blur/add" let i++ if [ "$((i%20))" == "0" ] ;then sleep 2 fi done
3.shell使用内容,if语句,while do语句。文件读取文本,数组,变量自增等。
备注:因为时间有限,先这样吧,以后逐步完善。