107

Is there any utility to make searches for a string inside ASCII files to avoid command line searches?

How to make a command line search, for example for the string "test" inside all files in the directory /var/x/?

Braiam
  • 69,112
Nuno
  • 1,187

9 Answers9

166

I assume that your first question is about a GUI alternative to the grep command. I can't help you with that, I always find the command line very effective.

As for the command line, try

grep "test" /var/x/*

If you want to search recursively (i.e. not only in /var/x/, but also in subdirectories thereof), do

grep -R "test" /var/x/

To avoid grepping the files which grep thinks to be binary, use the -I option:

grep -I "test" /var/x/

If grep thinks a file is binary (based on first few bytes of the file), it will assume it does not match instead of going through the whole file.

January
  • 37,208
82

You can use searchmonkey. The tool is available in the repositories, so you can simply

sudo apt-get install searchmonkey

On the other hand, command line search with grep is really intended for that...

Here is a screenshot from searchmonkey

enter image description here

Anwar
  • 77,855
alci
  • 5,979
22

You can use regexxer it is a great GUI search/replace tool for regular expressions.

you can download by:

sudo apt-get install regexxer

enter image description here

Seth
  • 59,332
8

Try Recoll, best GUI one I ever used. To install recoll in all currently supported versions of Ubuntu open the terminal and type:

sudo apt install recoll

It needs some time to index the files first (you can define blacklist path or extensions or mime).

karel
  • 122,292
  • 133
  • 301
  • 332
6

You can use the grep command from terminal:

grep -r string *

This command will find all occurrences of "string" in all the files under the current directory (or subdrectories).

For hidden files, you can use:

grep -r string ..

inquisitive
  • 169
  • 1
  • 4
3

Unfortunately grep does a very poor job of searching inside Word (.doc) files, but you can pipe catdoc output into grep. I'm no programmer but this little script works well for me:

#!/bin/bash
export GREP_OPTIONS='--color=auto'
echo -e "\n
Welcome to scandocs. This will search .doc (NOT .docx) files in this directory for a given string. \n
Type in the text string you want to find... \n"
read response
find . -name "*.doc" | 
while read i; do catdoc "$i" | 
grep -iH --label="$i" "$response"; done

All improvements and suggestions welcome!

Ralph
  • 139
2

I've just released a simple tool to do the job. Thought mainly for software developer, it has the (unique?) characteristic of openning several files in the same window. It presents the results in the browser using Ace editor (recomended!) or html textarea. It is a java based tool so it runs in windows as well as in linux.

check it out!

https://sourceforge.net/projects/queacetu.gastona.p/

1

per https://askubuntu.com/a/1141367/47073

You can use mate-search-tool, which is the same thing as gnome-search-tool that was removed. I had problems with searchmonkey, it was missing some results and was slow, do not recommend.

To install mate-search-tool:

sudo apt install mate-utils
mate-search-tool
Yrogirg
  • 381
1

You can use Sublime Text Find in Files option from Find menu to search for strings inside files from a folder.

To Install Sublime Text 3

sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

You can also follow this question for other possible ways of installing Sublime on Ubuntu.

To search in all files for a string from a folder in Sublime Text you can follow this question for more clear answers.

M.A.K. Ripon
  • 3,409
  • 3
  • 28
  • 36