Maybe you never needed to do it, maybe you tried it once and you resigned. In any case, I confirm what you probably already suspected: cannot search for text in file content from Nautilus. Just in case you're still lost trying to figure out how the hell to look up something in Nautilus, there's a button with a magnifying glass icon right next to the address bar (easier, hit Ctrl + F). From there, you can search for folders and files by name, but you cannot search for text in the content of the files. Then, how do we do? Here's the solution ... well, half. 🙂 |
Gnome-Search-Tool, just two clicks away ...
Go to Places> Find files… You can also run this tool by pressing Alt + F2 and typing gnome-search-tool.
Once the window is open, click where it says See more options. There it will allow you to enter the text to search. In addition, you will be able to enter other search parameters such as the modification date, the size, the owner of the file, etc.
Through the terminal
You may have used the command grep if knowing well what it is for. Well, it's time to learn.
It is a command that is used precisely to find text in the content of files. You can do all kinds of searches that you can think of. Like any terminal command, its secret lies in knowing the available parameters well.
We are going to give a concrete example. Suppose you want to search for all files containing the phrase "let's use linux" in your folder / media / win / stuff.
The command to execute would be:
grep -lir "let's use linux" "/ media / win / stuff"
The -l parameter tells you to print the names of the files in which the requested text is found. The -i parameter, which is case-insensitive. The -r parameter, which searches recursively within the specified path.
In case you want to restrict the search to a certain type of file, first go to the path where grep has to search.
cd / media / win / stuff
Then, I wrote something similar to this adapting it according to your needs:
grep -lir "let's use linux" * .pdf
For more information I suggest you write one was seized in a terminal. 🙂 The manual does not bite!
Well, I answer myself 🙂
grep -r "7005" * –include = *. xml
you can use –include or –exclude with -r
😀
How about Leo, it worked like this for me (with double «-» for the include):
grep -r "7005" * –include = *. xml
regards
A detail, in the last example: grep -lir "let's use linux" * .pdf, if I use * .xml (for example) it does not search recursively, but instead searches the directory with the form * .xml and not in all files * .xml that are in the subdirectories. I was just looking for the solution to this, does anyone know?
You could just use the * but that includes all files, this I want to avoid.
very good.
Perfect, clear and well explained.
How to improve indicate that in the command
grep -lir "let's use linux" "/ media / win / stuff"
the quotes should be left as follows
grep -lir "let's use linux" / media / win / stuff
regards
Exact. I put the quotation marks in case someone happened to replace my example with a path that includes spaces. I anticipated a future claim: hey, it doesn't work for me !! Haha…
Anyway, what you say is true. In the example there are plenty of quotes but if you want to enter a path that includes spaces, you must put quotes.
Made the caveat. Greetings and thank you very much for commenting!
Excellent contribution, very well explained: simple and easy to follow. Waiting for that future post that you announce at the end.
regards
Yes, I already added it to my to-do list! 🙂
Cheers! Paul.
Very good! really useful and works great!
Thank you!
Dear, seeing the content of your comments that I find encouraging, I decided to ask you for help with the video of ni lenovo T430 I am using linux Mint since version 9 now I installed version 17 KDE and I have problems with the resolution of the video I cannot use the 1920 × 1080 that has the plate. can you help me?
Thank you
ok man thank you served me !!! salu2
These details are what destroy the wonderful free systems, in the year 2015 and still cannot do a text search from the file browser? And the worst thing is that I remember that about 10 years ago it was possible, why do we go back in some basic things?
Yes, a simple command, yes, it is free, you have the code and others, but I think that this type of detail marks a novice user who approaches the world of gnu / linux.
We are talking about searching for content within files, not filtering them by name 🙂
It is always good to have these types of posts scheduled 😉
In MacOSX you can execute this command: (I suppose that in Linux it will also be there, since Linux and MacOSX are family, "little brothers".)
mdfind -onlyin [path of the directory where we will search] query ["text to search for"]
use quotation marks for a text with spaces. 😉
for example:
mdfind -onlyin Documents query curriculum
These commands and their great utility and that they share it so easily, save the country.!