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/
?
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/
?
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.
Binary file file.jpg matches
grep
to be coded, though I don't know if Ubuntu's grep
is written that way).
Commented
Oct 9, 2012 at 9:30
*
after the final slash in the path or grep does not appear to do any work in 14.04
Commented
May 19, 2016 at 13:35
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
You can use regexxer it is a great GUI search/replace tool for regular expressions.
you can download by:
sudo apt-get install regexxer
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).
gnome-search-tool
or search-monkey
. It uses Xapian, so it's able to inspect and index word documents (both .doc and .docx), pdf files, mail folders, etc.
sudo apt install recoll
) and it does its job where even grep fails, e.g. with .docx documents that are compressed with pkzip compression.
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 ..
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!
grep
and .doc
have to do with the question.
Commented
Jan 26, 2013 at 14:54
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!
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
You can use Sublime Text Find in Files
option from Find
menu to search for strings inside files from a folder.
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.