在同一文件夹中的 txt 文件中使用日志和参数进行卷曲
Curl with log and parameters inside a txt file in the same folder
我正在构建一个 .sh 脚本以 运行 基于文件 fileWithItems.txt 中的项目(每行)卷曲。
这是我构建的脚本:
declare -a array
#assuming fileWithItems.txt contains one element per line to be used in the url is in the same folder as this .sh
mapfile -t array < fileWithItems.txt
host="localhost"
port="PORT"
i=0
while [ ${i} -lt ${#array[@]} ] ; do
curl -X PUT "$host:$port/path1/${array[$i]}/refresh" > log.txt
((i++))
done
似乎没有正确构建 curl。如何优化?
为了进一步阐述我的评论,您可以这样做:
host="localhost"
port="PORT"
while IFS= read -r line; do
curl -X PUT "$host:$port/path1/$line/refresh"
done < fileWithItems.txt > log.txt
请注意 > log.txt
放在 done
之后,以免每次都覆盖相同的文件。
我正在构建一个 .sh 脚本以 运行 基于文件 fileWithItems.txt 中的项目(每行)卷曲。 这是我构建的脚本:
declare -a array
#assuming fileWithItems.txt contains one element per line to be used in the url is in the same folder as this .sh
mapfile -t array < fileWithItems.txt
host="localhost"
port="PORT"
i=0
while [ ${i} -lt ${#array[@]} ] ; do
curl -X PUT "$host:$port/path1/${array[$i]}/refresh" > log.txt
((i++))
done
似乎没有正确构建 curl。如何优化?
为了进一步阐述我的评论,您可以这样做:
host="localhost"
port="PORT"
while IFS= read -r line; do
curl -X PUT "$host:$port/path1/$line/refresh"
done < fileWithItems.txt > log.txt
请注意 > log.txt
放在 done
之后,以免每次都覆盖相同的文件。