Linux command to find all files in a directory which contain ip addresses.
Give a Linux shell command to find all files in a directory which contain ip addresses.
|
Hi and welcome to LQ.
Looks like homework. What have you tried so far? |
@sycamorex: this is not a homework question.It is an interview question.I actually wrote something like
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \; which displays all the IP addressess present in /etc directory.......actually i just want to display the file names in which IP addressess are present....how to do that??please help me |
Have a look at grep's -L and -l options.
|
@druuna: I could not get your clue.....It would be grateful if u provide me with the command
|
Did you have a look at the grep man page (man grep)?
Code:
find /etc -exec grep -L '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \; |
@druuna: Thank u so much for your patience in explaining me this...I got the answer now....Since I am just a beginner in linux it was difficult for me to grasp your clue....once again thank u so much for helping me :)
|
@druuna
I think the OP wants -l not -L Try: Code:
find /etc -exec grep -rl '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' {} \; |
Quote:
|
All times are GMT -5. The time now is 09:32 PM. |