Last active
December 23, 2015 23:09
-
-
Save vibol/6707670 to your computer and use it in GitHub Desktop.
Simple shell script to fetch a list of URLs from a text file in parallel. Text file should contain one URL per line. Usage: ./redirect.sh [filelist.txt] [numprocs]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE=$1 | |
PROCS=8 | |
if [ ! -z "$2" ]; then | |
PROCS=$2 | |
fi | |
if [ ! -z "$FILE" ]; then | |
echo "Processing: $FILE" | |
cat $FILE | xargs -I'{}' -P $PROCS curl -o /dev/null --silent --head --write-out '{}\t%{url_effective}\t%{http_code}\t%{redirect_url}\n' "{}" | |
else | |
echo "Usage: $0 [urllist.txt] [numprocs]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment