linux: shorter 'host' command output

Solution 1:

Use dig(1) with the +short flag instead:

$ host -t txt google.com
google.com descriptive text "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"

$ dig -t txt google.com +short
"v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"

If you want to remove the quotes, just filter the output through sed:

$ dig -t txt google.com +short | sed 's/"//g'
v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all

Solution 2:

My first choice would be dig as dawud pointed out. If you stick with 'host', you could replace sed with:

cut -d \" -f 2