似乎无论何时我在shell上测试它都可以,但是当我从脚本运行它时它不会。
外壳:
fips=55555
echo https://www2.census.gov/geo/tiger/TIGER2016/ROADS/tl_2016_$fips'_'roads.zip
>>https://www2.census.gov/geo/tiger/TIGER2016/ROADS/tl_2016_55555_roads.zip
我正在尝试在文本文件中循环浏览一些数据:
将其解析/输入到curl url:
但是输出的字符串的开头是这样覆盖的:
./readFipsData.txt
>>_roads.zipw2.census.gov/geo/tiger/TIGER2016/ROADS/tl_2016_48001
注意:如果有任何不同,我正在使用Git Bash for Windows。
cat ./testFipsData.txt |
while read line
do
counter=0
for col in $line
do
if [ $counter == 0 ]
then
state=$col
elif [ $counter == 1 ]
then
county=$col
elif [ $counter == 2 ]
then
fips=$col
fi
((counter++))
done
#curl -k -o ./$county.zip "https://www2.census.gov/geo/tiger/TIGER2016/ROADS/tl_2016_$fips_roads.zip"
echo https://www2.census.gov/geo/tiger/TIGER2016/ROADS/tl_2016_$fips'_'roads.zip
done
答案 0 :(得分:0)
感谢您在这里提出的所有建议:
cat ./testFipsData.txt |
while read state county fips
do
fips=${fips%$'\r'}
curl -k -o ./$county.zip https://www2.census.gov/geo/tiger/TIGER2016/ROADS/tl_2016_$fips'_'roads.zip
done