Results 1 to 10 of 10
My entire server is huge so i dont wanna download all the files to search for a code in wingrep/powergrep so i am looking for a solution to do the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-12-2012 #1Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
How to search a code throughout the server? (Like a wingrep)
My entire server is huge so i dont wanna download all the files to search for a code in wingrep/powergrep so i am looking for a solution to do the same in a centos VPS server.
- 09-13-2012 #2
Could you ssh into the VPS and use regular grep over your web directories? You'd not be searching files over a network then, it'd be done on the VPS itself and you'd see the results in your ssh terminal.
Linux user #126863 - see http://linuxcounter.net/
- 09-13-2012 #3Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
That sounds so cool. I wish i couldnt do that but i use windows and putty to get connected to ssh. So can you give me more details on how to do it?
- 09-13-2012 #4
Connect via putty.
Use grep.
Code:man grep
You must always face the curtain with a bow.
- 09-13-2012 #5Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
- 09-13-2012 #6Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
Could you give me an example of a command to search for like "preg_replace" throughout the entire server and show me the process and the results right away?
There are so many options and i actually got lost in them. Tried few things but couldnt really success.
- 09-13-2012 #7This will search the entire filesystem for preg_replace. / is the directory you're searching, and in this case it's the root of the filesystem. Here's an example of searching everything under the current directory:Code:
grep -Rn preg_replace /
As you can see it tells you what file it occurred in and on what line, which means you can go straight to the desired line.Code:grep -Rn main . ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:16: main () ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:20: printf ("mainvar == %d\n", mainvar); ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:24: printf ("shlib_checkfunptr2 (main_called) == %d\n", ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:25: shlib_checkfunptr2 (main_called)); ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:48:- if (p == main_called) ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:52:- printf (" main_called\n"); ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:58:+ if (p == main_called) ./public_html/uploads/patches/binutils-2.19.1-testsuite.patch:62:+ printf (" main_called\n");
- 09-13-2012 #8Just Joined!
- Join Date
- Aug 2012
- Posts
- 54
Perfect. Thx.
- 09-13-2012 #9
If you are getting to may results, you can send the output to a file for further analysis by (to nick the prior example)
which will put the output in a file called grep.txt in your home directory.Code:grep -Rn preg_replace / > ~/grep.txt
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
The Fifth Continent reborn
- 09-13-2012 #10


Reply With Quote

