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.
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.