Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Grep 1

Status
Not open for further replies.

coach38

MIS
Apr 8, 2004
104
0
0
US
I'm a newbie

I'm tying to search for an ip address located in one of the files in the path below. I'm getting nothing back. I've tried several different ways. Am I missing something from this command line below.

grep '10.90.65.24' /data/autoprod/extern/ftp-it/profiles/*.*
grep '10.90.65.24' /data/autoprod/extern/ftp-it/profiles*
grep '10.90.65.24' /data/autoprod/extern/ftp-it/profiles/*
grep '10.90.65.24' /data/autoprod/extern/ftp-it/profiles/.*

jd

 
Are you sure the IP is in there somewhere?

Try your [tt]grep[/tt] commands with just '10.90' as the search pattern and see if that finds anything...

HTH,

p5wizard
 
ok, but command line from the above should I use. I did know if I was putting the astrisk in the correct place.
 
If [tt].../profiles[/tt] is a directory, then only 1st, 3rd and 4th make sense to me, and 1st not really

[tt].../profiles/*[/tt] - all visible files in the dir
[tt].../profiles/.*[/tt] - all invisible (hidden) files in the dir


HTH,

p5wizard
 
if I'm in the directory do I have to list the entire path

the ip address is listed like this

ftpserv=10.90.65.24
 
No you shouldn't need the full path.
Code:
grep 'ftpserver' *
Should give you all lines with that word in, in the files in you current directory.
 
Got it! This one worked


grep '10.90.65.24' /data/autoprod/extern/ftp-it/profiles/*

thanks

 
Be aware though when using grep that . can match any character, so if there was a typo such as "10>90.65.24" in the file, it would still match.

Also it would match substrings such as "110.90.65.241". The safest way to match that exact IP address only would be grep -w '10\.90\.65\.24' /data/autoprod/extern/ftp-it/profiles/*.

Annihilannic.
 
Or you can use [tt]fgrep[/tt]. It will treat the dot as a dot, not a single character wildcard.
Code:
fgrep '10.90.65.24' /data/autoprod/extern/ftp-it/profiles/*


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top