-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·36 lines (31 loc) · 916 Bytes
/
script.sh
File metadata and controls
executable file
·36 lines (31 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Change this value to match the name of your Kotlin file
FILE="$1"
# Split the file names into an array
IFS=',' read -ra FILE_ARRAY <<< "$FILE"
# Use grep to find all the URLs in each file
URLS=""
for filename in "${FILE_ARRAY[@]}"
do
urls=$(grep -o 'https\?://[a-zA-Z0-9./?=_&-]\+' "$filename")
URLS="$URLS $urls"
done
# Check the status code of each URL with curl, following redirects
i=0
failed_urls=()
for url in $URLS
do
# GET the URL and follow up on redirects
status_code=$(curl -L --silent --head --output /dev/null --write-out '%{http_code}' "$url")
if [ "$status_code" -ne 200 ]; then
echo "$i: $url - Failed (HTTP $status_code)"
failed_urls+=("$url")
fi
((i++))
done
# If there were failed URLs, exit with an error
if [ ${#failed_urls[@]} -gt 0 ]; then
echo "The following URLs failed:"
printf '%s\n' "${failed_urls[@]}"
exit 1
fi