Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-19-2009, 05:42 AM
|
#1
|
Member
Registered: Sep 2007
Location: Bangalore,India
Distribution: Fedora,Mandriva,Debian
Posts: 180
Rep:
|
dispalying IP address using echo
Using these commands,i can display the IP address of my address:
ifconfig eth0 | grep "inet addr" | cut -d: -f 2
awk 'print $2'.
But i dont have awk in my embedded system,and i want 2 use "echo".
How i could dsiplay ip address.
Regards,
Ravi
|
|
|
03-19-2009, 05:50 AM
|
#2
|
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847
Rep: 
|
Perhaps if you don't have awk, you may have cut? It'll do something as simple as this without breaking a sweat.
|
|
|
03-19-2009, 06:13 AM
|
#3
|
Member
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267
Rep:
|
Just echo the output of your ifconfig line:
echo `ifconfig eth0 | grep "inet addr" | cut -d: -f 2`
Dave
Or, easier to see using this format (same command though)
echo $(ifconfig eth0 | grep "inet addr" | cut -d: -f 2)
and adding the other cut as pwc101 suggested to clean it up:
echo $(ifconfig eth0 | grep "inet addr" | cut -d: -f 2| cut -d\ -f 1)
Last edited by david1941; 03-19-2009 at 06:39 AM.
|
|
|
03-19-2009, 06:40 AM
|
#4
|
Member
Registered: Sep 2007
Location: Bangalore,India
Distribution: Fedora,Mandriva,Debian
Posts: 180
Original Poster
Rep:
|
i am getting my output as:
192.168.1.11 Mask.I dont want this mask field.I want to remove it,i have
tried various options,but not able to do so.
Please help.
Regards,
Ravi
|
|
|
03-19-2009, 06:44 AM
|
#5
|
Member
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267
Rep:
|
I'm sorry, I added pwc101's suggestion as an edit above and should have reposted.
echo $(ifconfig eth0 | grep "inet addr" | cut -d: -f 2| cut -d\ -f 1)
Dave
|
|
|
All times are GMT -5. The time now is 02:14 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|