Posted by StandupMedia, 01-11-2010, 03:33 PM | Hi,
I have fogotten the command that will search all files in the /home directory for a word i am looking for and save the list of files that has it in in a text file on the server.
Can anyone help me with this please?
Thank you in advance.
|
Posted by DigitalLinx, 01-11-2010, 03:40 PM | To find a file name.
If you want to search the files containing a word
Will take a while to finish depending on the amount of files. For case insensitive grep use grep -iR rather than grep -R.
|
Posted by StandupMedia, 01-11-2010, 04:48 PM | yea i know that but whats the code to save the result in a text file?
Thats what im after as i can not remember that part.
Thanks
|
Posted by DigitalLinx, 01-11-2010, 04:50 PM |
|
Posted by Beast5, 01-11-2010, 05:45 PM | a faster method to search files, is to relay on the locate database.
run one time the command " updatedb " , the system will hang a bit and create a search database.
after your database is created, simply use the command
where " myfiles" is the name of what you are looking for.
in order to create a file with a list of matches, you can use output redirection,
simply add
> results.txt
your command will look like this:
this will be much faster the next time you search for a file ( considering the database is already created ).
:-)
|
Posted by LeaTrueman, 01-12-2010, 01:04 AM | here you need to search for a word in all your files under /home folder. For this , please use grep command. If you want to search the word "common" in all your files,
grep -ir common /home >> /home/testfile
hope this command helps you.
|
Posted by ianeeshps, 01-12-2010, 03:13 AM | locate finds the results from a database. It will not give last createated data..........you need to run updatedb if u need more accurate result for locate.............apart from this locate is really fast I agree with that
|
Posted by LeaTrueman, 01-12-2010, 05:14 AM | Hello,
locate and find command will not search for a word inside a file. It will give only the filenames which contains the word in its name.
|
Posted by madaboutlinux, 01-12-2010, 05:44 AM | Use the following command, it's much faster:
|
|
Add to Favourites
Print this Article |