Last Updated: February 25, 2016
·
1.288K
· sheerun

GET webpage using only bash (no CURL involved)

get() {
  local address=${1##*//}
  local host=${address%%/*}
  local path="${address#$host}"
  exec 3<> "/dev/tcp/$host/80"
  echo -e "GET $path HTTP/1.1\nHost: $host\nConnection: close\n\n" >&3
  cat <&3 | sed "1,/^.$/d"
}

get http://www.google.com/foobar