1 liner question

This works:

nslookup `uname -n`|tail -2|awk -F: '{print $2}'

This does not

aa=`nslookup `uname -n`|tail -2|awk -F: '{print $2}'`

Why???

Solaris v10

Thanks
Brandt

Some shells have a problem with backtics inside backtics use : $( ) instead.

Because you need to escape the inner backticks:

aa=`nslookup \`uname -n\`|tail -2|awk -F: '{print $2}'`

I believe there is a better way to extract the above information though ...

What would be the better way? Please & Thanks!!

Radoulov,

Your backticks worked well, I will use that!!

Thanks All!!

If your shell supportsthe $() syntax for process substitution:

addr="$(perl -MSocket -e'
  print inet_ntoa(~~gethostbyname$ENV{"HOSTNAME"})
  ')"

Or:

addr="$(nslookup "$HOSTNAME"|nawk '/^Add/&&c++{print $NF}')"

Or:

addr="$(getent hosts "$HOSTNAME"|cut -f1)"

All works!!

Again Thanks!!

Brandt