ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I'm trying to find out two things here, if there is an easy way to find out the network configuration file that the network interface has been assigned to eg:
1. My linux machine has ifcfg-eth0 but if you had more interfaces this file might be ifcfg-eth1, or ifcfg-foobar.
Anyway the point is the IP address could be on any type of network interface therefore i can't hard code into my script which file the ip address is configured in because it will change depending on the interface being used for the connection, and as this is a script i want it to be able to find out itself. Is there a way to do this??
2. One idea i came up with is to search all the network interface config files and then get it to return the file with the ip address settings in it, i could do this with grep but wonder how you can get grep if possible to search for more than one argument at a time i.e
grep -R if '192' && '255' && '543'
so i'm saying if a file contains '192' '255 '543' anywhere in its contents then as grep does, print out the path to that file. I just dont know if its possible to get grep to search many strings in a file all at the same time??
So if there is an answer to number 1. i'm very interested, but as a compromise and answer as to if grep with several strings for arguments is possible would be great and probably do the job to?
Yeah like that, but i basically just want to know if you can get grep to match more than one text string within a file, but i dont know if it is able to match more than one set of strings in a file.
So if file contains 'the' and 'help' and 'blah' and 'foobar' then that is the correct file and print the file's path to stdout including the file name.
ps- to be honest i doubt you'd need the for look as grep can look in all the files and print output of which file anyway, so all i really need is to know if you can grep for several things at once and how?
Last edited by helptonewbie; 11-08-2007 at 03:38 AM.