Bash | oneliner | curl |试图循环文件并将其提供给curl,但它抛出了错误?
我正在尝试遍历Bash | oneliner | curl |试图循环文件并将其提供给curl,但它抛出了错误?,bash,sorting,for-loop,curl,sed,Bash,Sorting,For Loop,Curl,Sed,我正在尝试遍历文件.txt,该文件包含%.google.com等域,并使用curl和URLcrt.sh从证书中提取HTTPS网站子域 不幸的是,它抛出了一个错误 parse error: Invalid numeric literal at line 1, column 20 script.sh 由于您正在尝试,您需要稍微改变您的方法 下面的示例在我的环境中工作,并且有一些用于调试和更好地理解的增强功能 #!/bin/bash while IFS= read -r line; do ec
文件.txt
,该文件包含%.google.com
等域,并使用curl
和URLcrt.sh
从证书中提取HTTPS网站子域
不幸的是,它抛出了一个错误
parse error: Invalid numeric literal at line 1, column 20
script.sh
由于您正在尝试,您需要稍微改变您的方法
下面的示例在我的环境中工作,并且有一些用于调试和更好地理解的增强功能
#!/bin/bash
while IFS= read -r line; do
echo"";
# Added for easier debugging and understanding
URL="${line}";
echo ${URL};
echo "";
# Added switches for easier debugging
# -i, include the HTTP-header in the output
# -w, display http_code on stdout after a completed and successful operation
curl --silent -x "localhost:3128" --include 'https://crt.sh/?q=${URL}&output=json' --write-out "\n\n%{http_code}\n"; # | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u;
curl -s 'https://crt.sh/?q=${URL}&output=json' | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u;
echo "";
done < URLs.txt
#/bin/bash
而IFS=读取-r行;做
回声“;
#为便于调试和理解而添加
URL=“${line}”;
echo${URL};
回声“;
#添加了开关,以便于调试
#-i,在输出中包括HTTP头
#-w,在操作完成并成功后在标准输出上显示http_代码
curl--silent-x“localhost:3128”--include'https://crt.sh/?q=${URL}&output=json'--写出“\n\n%{http\u code}\n”#jq-r'.[].name|u value'| sed's/\*\.//g'| sort-u;
旋度https://crt.sh/?q=${URL}&output=json'|jq-r'.[];
回声“;
完成
也可以将其更改为一行。是否尝试?这是一个
jq
错误,意味着“JSON”不是正确的JSON。例如:echo'[{“name_value”:3x2}].\jq-r.[].name_value'
。检查您从curl
@WiktorStribiżew中得到的确切信息是的,我有一个域列表,需要提供给这个curl-shttps://crt.sh/?q\=$1\&output\=json | jq-r'.[]
#!/bin/bash
while IFS= read -r line; do
echo"";
# Added for easier debugging and understanding
URL="${line}";
echo ${URL};
echo "";
# Added switches for easier debugging
# -i, include the HTTP-header in the output
# -w, display http_code on stdout after a completed and successful operation
curl --silent -x "localhost:3128" --include 'https://crt.sh/?q=${URL}&output=json' --write-out "\n\n%{http_code}\n"; # | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u;
curl -s 'https://crt.sh/?q=${URL}&output=json' | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u;
echo "";
done < URLs.txt