scripts

My personal collection of scripts
git clone git://src.gearsix.net/scriptsscripts.zip
Log | Files | Refs | Atom | README | LICENSE

openurl.sh (raw) (445B)


   1 #!/bin/sh
   2 # openurl
   3 # description: xdg-open all urls found in $@
   4 # e.g.$ openurl saved-links.txt
   5 
   6 open=xdg-open
   7 if [ "$(uname)" = "Darwin" ]; then open=open; fi
   8 
   9 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  10 	echo "usage: ./openurl.sh FILEPATHS..."
  11 	echo ""
  12 	echo "open all links existing in contents of listed files"
  13 	exit
  14 fi
  15 
  16 for f in "$@"; do
  17 	while read -r url; do
  18 		$open "$url" | grep -q 'https?://(^")+' | tr -d '\r'
  19 	done < "$f"
  20 done
  21