티스토리 뷰

728x90

[Shell] URL status 검증하는 url_status.sh




[url_status.sh]

#!/bin/sh
# input: curl -o /dev/null --silent --head --write-out '%{http_code}\n' <url>
# output: 200

lines=()
while IFS='' read -r line || [[ -n "$line" ]]; do
lines+=("$line")
done < "$1"

for url in "${lines[@]}"
do
for status in $(curl -o /dev/null --silent --head --write-out '%{http_code}\n' ${line})
do
echo ${status} ${url}
done
done


[url_list.txt]

http://music.naver.com


[출처] https://stackoverflow.com/questions/6136022/script-to-get-the-http-status-code-of-a-list-of-urls

728x90

'공부' 카테고리의 다른 글

[Java] Enum get value by key  (0) 2018.11.21
[JS] 현재창 묻지 않고 닫기 (window.close)  (0) 2018.11.21
[Linux] bash locale 설정하기  (0) 2018.11.07
[Java] POJO(Plain Old Java Object)  (0) 2018.11.02
[Jenkins] 가이드(guide)  (0) 2018.11.02
댓글