Skip to content

Instantly share code, notes, and snippets.

@vibol
Last active December 23, 2015 23:09
Show Gist options
  • Save vibol/6707670 to your computer and use it in GitHub Desktop.
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]
#!/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