Stupid Bash Scripts – Batch redirect resolving with curl
- July 11th, 2009
- By fuzion
- Write comment

I had a bunch of lists of redirects that I needed to get the targets for so I wrote this simple script to do it with curl. I’m sure you can do a lot more with this as a template so I decided to share.
#!/bin/bash # # # | _) | | | # \ | | | / -_) | _| _` | _ \ _| _ \ _| _` | # _| _| \_,_| _\_\ \___| _| \__| \__,_| \___/ \__| \___/ _| \__, | # ____/ # http://nukeit.org # # #Use curl to grab the headers from a list of redirects with grep and awk thrown in for fun. # # #set this to your directory of txt lists containing one redirect per line DIR="./unresolved/" #make a directory for the output files and put the name here OUTDIR="./resolved/" #Connect timeout in seconds CTIME="15" #Max timeout in seconds MTIME="30" #set proxy (untested) #http_proxy="" # cd $DIR for i in $( ls -1 ); do curl --connect-timeout $CTIME -m $MTIME -I $(cat $i) | grep Location | awk '{print $2}' >> ../resolved/$i; done