intensity
09-11-2001, 01:55 AM
I'm trying to search a lot of files for a particular string on my webserver and don't know what command to use. I only have shell access. Thanks.
|
Click to See Complete Forum and Search --> : Searching multiple file contents from command line intensity 09-11-2001, 01:55 AM I'm trying to search a lot of files for a particular string on my webserver and don't know what command to use. I only have shell access. Thanks. Craig McPherson 09-11-2001, 01:59 AM You can search every file in a directory like this: grep -n * searchstring You can also search all subdirectories as well by adding the -r option. See the grep manpage for more options. intensity 09-11-2001, 02:11 AM Thanks Craig! :) intensity 09-11-2001, 02:40 AM Sorry, I have another question. So my search string is an IP address. In the man pages it says that the period matches any single character. Am I correct in using a backslash allows me to do the search I want? Thanks again. :D Craig McPherson 09-11-2001, 03:12 AM Yes, backslashing the dots will give you the search you want. You probably don't have to, though: it's true that grepping for "111.111.111.111" without the periods backslashed will also match "111b111C1114111", but there's probably not much chance that you'll have something like that in your files anyway. I almost forgot, you can also just use the -F option, and it'll interpret your entire search string litterally, so you won't have to backslash the periods. You can also use "fgrep": "fgrep" is the same as "grep -F" justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |