The single quotes prevent the variable from expansion, so the literal name is inserted. Try using double quotes instead, and don't escape the $ with the \ . Some sed s insist on a line break before the insertion text.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
echo "what is the website ?"
read WEBSITE
if grep -q $WEBSITE "/etc/squid3/acls/allowed-sites"
then
echo "$WEBSITE already exists"
else
echo "adding website $WEBSITE"
sed -i -e "3i$WEBSITE\" /etc/squid3/acls/allowed-sites
fi
and now im getting this error
/usr/local/sbin/add-website.sh: line 19: unexpected EOF while looking for matching `"'
/usr/local/sbin/add-website.sh: line 22: syntax error: unexpected end of file
my crystal ball says there's no matching double-quote on line 19 of your script. sed -i -e "3i$WEBSITE\" /etc/squid3/acls/allowed-sites
What exactly is the purpose of \" ?