ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
Its probably something simple but no matter what I try the field always comes up blank, the problem is this, all I need is for a script to run and store the current ip address in a field for later use
I cant find much from google and the closest Iv I come to is on LinuxQuestions, but Im still new and dont understand a much about awk
Edit: In this example, I've called the variable "ip". Of course, you're free to choose your own name! Then, when you want to get the value stored in that variable, you prefix the name with a $ (so, to print it for example, you'd use "echo $ip").
Did anyone (else) have trouble with that bash snippet ???.
Failed on bash 3.2.21 - invalid substitution. Worked o.k. on 3.2.25
Strange, worked with 2.05b.0(1), 3.2.9(1), 3.00.0(2)-bashdiff-1.44
(on my notebook with 3.2.25(1)).
I'm trying to figure out which option could make it fail.
Mmmm - very odd. Only fails on Ubuntu systems (so far). One 7.04 (bash 3.2.21) and one 7.10 beta (bash 3.2.25).
Arch and Gentoo work fine - I'll see what I can suss out.
Mmmm - very odd. Only fails on Ubuntu systems (so far). One 7.04 (bash 3.2.21) and one 7.10 beta (bash 3.2.25).
Arch and Gentoo work fine - I'll see what I can suss out.
Could you try it like this:
Code:
set -- $(LC_ALL=C ifconfig eth0)
printf "%s\n" "${7/addr:}"
Thanks for the replys I wasn't expecting such a response from what I thought was a simple question, obviously theres a lot of variants as to the version your using, a lot of the posts are a bit over my head so I'm not going to comment on them, but thanks again
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.