Skip to content

Instantly share code, notes, and snippets.

@ddksr
Last active November 17, 2015 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddksr/f3b6fa65f2ea35c1e6e9 to your computer and use it in GitHub Desktop.
Save ddksr/f3b6fa65f2ea35c1e6e9 to your computer and use it in GitHub Desktop.
Favorite bash snippets
# In a file with urls, count different status codes
{ for line in `cat urls.txt`; do curl -I $line 2> /dev/null | head -n 1 | egrep -o '[0-9]{3}' ; done; } | sort | uniq -c
# Get titles from urls from clipboard
urls=`xclip -o | tr '\n' ' '`; for url in $(echo $urls); do clean_url=$(echo -e "${url}" | tr -d '[[:space:]]'); tmp=$(curl "$clean_url" 2> /dev/null | egrep -o '<title>.*</title>' | egrep -o '>.*<'); echo ${tmp:1:-2}; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment