26

I am looking for a software that will search text in files from a folder similar to XYplorer.

Is there something similar?

Octavian Helm
  • 14,355
S L
  • 1,919

10 Answers10

21

There is a very nice one that shipped with Ubuntu out of the box until 16.04. For modern releases, read the update below!

  1. Open the Dash (Super key or the Ubuntu button) and begin typing until you find Search for Files

    enter image description here

  2. The above is for Unity, the default Desktop Environment in Ubuntu. In menu-driven environments, go to Applications -> Accessories -> Search for Files

    enter image description here

  3. Expand the Select more options section and enter the text to search for in the Contains the text: input field.

    enter image description here

Features:

  • 100% GUI
  • You can search for file names or content
  • It does look in sub-folders.

Given your scenario (no terminal commands, simple to use interface) I think theres no better option.

PS: on the Contains the text: input field the '.' character is a wildcard. To escape it you have to use '[]'. E.g.: type Contains the text: [.]myFunction to search for .myFunction


UPDATE: Gnome Search Tool was unfortunately removed from Ubuntu on early 2018. For Ubuntu 18.04 onwards there's mate-search-tool, from the mate-utils package, that looks and behave exactly like the defunct Gnome tool:

sudo apt install mate-utils
mate-search-tool

However, its associated .desktop launcher does not show by default in Gnome/Unity menu, but a simple edit can workaround that:

sed '/^OnlyShowIn/s/^/#/' /usr/share/applications/mate-search-tool.desktop \
> "$HOME"/.local/share/applications/mate-search-tool.desktop
MestreLion
  • 20,086
  • yup, I didn't see i could add details – S L Mar 08 '11 at 13:43
  • 1
    yes, you can... just click on "select more options" and you can have not only "Contains the Text" but also tons of other search options (date, user, file sizer, even regex expressions). I also missed this little beast for a long time... i wish it was integrated into Nautilus (kinda like F3 in Windows Explorer) – MestreLion Mar 08 '11 at 13:53
  • this is the same as i advised earlier gnome-search-tool – Mikl Mar 08 '11 at 14:19
  • @Octavian: Thanks for providing the screenshots! – MestreLion Mar 09 '11 at 16:02
  • @Mikl: its the same result, the difference lies in approach on how to invoke it: your initial solution was focused on command-line invocation (or ALT+F2) and only briefly mentioned it could also be found on menu. Didnt say where, or what the program name was in the menu. Only after i post my answer you edited yours to provide the menu path and name. For newcomers, a Menu-oriented approach is always better than CLI invocation. ALT+F2 should only be used when the software is not avaliable in menu. – MestreLion Mar 09 '11 at 16:10
  • I'm not sure this tool still exists in this form after the Unity button. The answer by @wizztjh works though. – Aleksandar Savkov Mar 05 '14 at 11:10
  • could someone help to find out where is this tool please? for Ubuntu 20.04. I searched this tool, it's not there anymore. How to get it back? – Franva Mar 07 '21 at 01:52
  • @Franva: it was removed from Ubuntu since 18.04. You could use the similar mate-search-tool: sudo apt install mate-utils – MestreLion Mar 09 '21 at 09:52
  • @MestreLion thanks for letting know. I went with SearchMonkey and it looks good as well :) have you tried to compare these 2? – Franva Mar 10 '21 at 10:43
  • @Franva, nope, never used SearchMonkey. Gnome/Mate Search Tool is fine for me as a simple find GUI, for anything more complex I prefer using grep and find directly on terminal – MestreLion Mar 12 '21 at 13:39
  • 1
    @Franva: Also, I usually tend to avoid software that's not in the repositories. SearchMonkey in particular does not even have a .DEB installer yet. It seems the project was inactive for 10 years , still uses GTK2, and was revived in 2018 (possibly due to Gnome Search Tools being deleted from Ubuntu). Hopefully they'll migrate away from SourceForge to a proper GitHub hosting, and re-active their currently suspended website. They have a lot of catching up to fill this 10-year gap of inactivity. – MestreLion Mar 12 '21 at 13:49
  • @MestreLion good point. thanks :) – Franva Mar 14 '21 at 22:57
11

use

 grep -nr <your text> .

put the text that you want to find inside the <your text>

Octavian Helm
  • 14,355
wizztjh
  • 303
10

I am a fan of searchmonkey (GPL, free, cross-platform, pretty light on resources and very fast).

enter image description here

Will
  • 706
  • 7
  • 14
10

you can use

find . -name '*.*' -exec grep -Hn 'text to find' '{}' \;

-name '*.*' or '*.txt' (use file mask here)
'text to find' (place text you want to find here)

find . -type f -exec grep -Hn 'text to find' '{}' \;

if you want to search all files

Mikl
  • 461
  • For all files, do not use -name '*.*' as files do not always have an extension. Use -type f instead (for searching in all files). Replace {} by "{}", otherwise file names with whitespace in it do not get searched correctly. – Lekensteyn Mar 08 '11 at 12:31
  • @Lekensteyn i have edited my post. but i made some test with files with whitespaces in names and no error while using {} witout quotes. – Mikl Mar 08 '11 at 13:43
  • just tested it too and you are right, whitespace is not a problem. In some shells, the quotes might still be necessary to prevent shell expansion. From man find: "Both of these con‐ structions might need to be escaped (with a `') or quoted to protect them from expansion by the shell." – Lekensteyn Mar 08 '11 at 14:13
9

GUI (Graphical) tool:

gnome-search-tool

you can find it in Ubuntu main menu

Menu -> Accessories -> Search for Files

or run it using hot key ALT+F2

Mikl
  • 461
  • 1
    Just an update for newer Ubuntu versions: on Unity interface (Ubuntu 12 or superior), click on Dash Home (the first icon on toolbar), type "search" and select "Search Files" application. – josircg Dec 09 '13 at 13:09
4

Regexxer will let you search text in files. Not sure what you mean by "in folders".

enter link description here

Seth
  • 58,122
uvasal
  • 513
3

Graphical search:

in Kubuntu open Dolphin, then Edit->Find (Ctrl+F)

change from filename to Content and adjust from where to look for.

Osis
  • 703
2

Recoll does indexing and you can do full text searches of documents and email.

Dustin
  • 2,103
  • Looking into 50.000 folders is a pain :D if you don't index the data, so if you cannot buy a SSD disk, install any indexing tool before you waste time looking for files. Do the job once. Even if is not an answer to current question is a good point of view. – m3nda Aug 30 '15 at 15:54
1

I compared three of the suggestions in here with 64 bit 16.04 Kubuntu:

  1. Searchmonkey works with 64-bit Ubuntu nowadays. It is similar to regexxer. It appeared fast, but naturally it is much slower than index based search.
  2. Search for Files and Alt-F2 don't work with the KDE Ubuntu version.
  3. My recommendation is Recoll and I have added some installation instructions for it. For me, the default installation supported PDF (test this!), DOCX, TAR, ZIP etc.

    sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
    sudo apt-get install recoll antiword
    recoll
    
  4. First line is probably not required: it adds partner installation repository.

  5. Antiword is optional. It is needed to support older .doc files.
  6. Enable following symbolic links and the root directory from Recoll Preferencies if necessary.
  7. Create cron job for Recoll indexing using the GUI or make it to start on every login.
  8. Change the Recoll setting in preferences from English to All languages if appropriate for you.
  9. Start the indexing, at least for me it was surprisingly fast and didn't use all resources so I was able to continue using the laptop.
  10. I have found one bug from Recoll so far: if you search for file name with "PST", it doesn't find it even though it is in uppercase. "pst" works and it finds both uppercase and lowercase names.
  11. See more about recoll from https://www.lesbonscomptes.com/recoll/features.html

If you wish to add support for Outlook PST files, then you need to execute the following as well.

    sudo apt-get install readpst
    mkdir ~/PST
    find -L ~ -name "*.pst" -print | awk "{ printf \"%s%s %s%s%s %s\\n\", \"mkdir ~/PST/\", \$1, \"; readpst -o ~/PST/\", \$1, \" -D -j 4 -r -tea -u -w\", \$1 }" > /tmp/myPstFiles
    cat /tmp/myPstFiles
    chmod 755 /tmp/myPstFiles
    /tmp/myPstFiles
  1. Change root directory from ~ to / if necessary in the find command.
  2. My find script has a bug in it: it creates too long directory structure now. But it was easier for me to modify the temp file manually than to find a fix to this. Main target was that this will work for several PST files and it does that.
  3. See more about Readpst from http://www.five-ten-sg.com/libpst/rn01re01.html and https://blog.robseder.com/2015/08/29/working-with-a-pst-file-in-linux/
0

I'm really want to introduce one tool which is based on ncurses library to provide the text-based user interface. The tool called NCGREP(grep based on ncurses) is mainly for search text in the specific folder. Hope this is what you want. This source of the tool has been hosted on github.com, see more at https://github.com/ncgrep/ncgrep

enter image description here
Click image to see demo animation

karel
  • 114,770