I know this is a simple question, but I can't recall a method of doing it. I wrote a service using automator to copy the public URL of a file in my Sites folder. I wrote this script:
sed -e 's/:/\//g' -e 's/\ /%20/g' -e "s/^\/Users\/$USER\/Sites/http:\/\/$HOST\/~$USER/g" | pbcopy
But $HOST only has my computer's name, not including the domain. I figured out that I can do this:
host $HOST myname.mydomain.com has address 18.104.22.168
I know I can use this to pull the domain name out:
set FULLHOST=`host $HOST | perl -pne 's/ has address .*//;$_=lc'` sed -e 's/:/\//g' -e 's/\ /%20/g' -e "s/^\/Users\/$USER\/Sites/http:\/\/$FULLHOST\/~$USER/g" | pbcopy
but I'm curious, is there a cleaner command that will just give me back either the domain (mydomain.com) or the full address (myname.mydomain.com)?