LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to get only ip address of host (https://www.linuxquestions.org/questions/linux-general-1/how-to-get-only-ip-address-of-host-839269/)

hussain.s 10-20-2010 08:23 AM

how to get only ip address of host
 
hi,
my problem is when iam typing


a=host test.com
echo $a


output
test.com has address 17.108.43.86

now i want to print only address (17.108.43.86) and don't want to print this line [test.com has address] how to do this

onebuck 10-20-2010 08:46 AM

Hi,

Sure looks like 'homework' to me.

Maybe you should review the LQ Rules;
Quote:

Do not expect LQ members to do your homework - you will learn much more by doing it yourself.
Start out at items 4, 5 and 6 below.

Just a few links to aid you to gaining some understanding;

1. Linux Documentation Project
2. Rute Tutorial & Exposition
3. Linux Command Guide
4. Bash Beginners Guide
5. Bash Reference Manual
6. Advanced Bash-Scripting Guide
7. Linux Newbie Admin Guide
8. LinuxSelfHelp
9. Getting Started with Linux

:hattip:

The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!

hairysocks 10-20-2010 08:52 AM

I won't give the full solution (because it does look like homework), but try the "read" command on the output from "host" in a script.

XavierP 10-22-2010 05:06 AM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


All times are GMT -5. The time now is 08:40 AM.