Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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/?

share|improve this question
9  
You really mean without using command line ? Because the best tool for that remains grep... –  alci Oct 9 '12 at 8:39
add comment

5 Answers 5

up vote 26 down vote accepted

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

share|improve this answer
add comment

Try Recoll, best GUI one I ever used, you can get it here: http://www.lesbonscomptes.com/recoll/

share|improve this answer
add comment

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!

share|improve this answer
    
This question was about graphical applications and plain text files. I'm not sure what grep and .doc have to do with the question. –  Andrea Corbellini Jan 26 '13 at 14:54
    
Seems OK, see January's detailed answer about grep. –  aquaherd Jan 26 '13 at 14:58
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
1  
Will it work if the folder contain some non-ascii files? –  Anwar Shah Oct 9 '12 at 8:47
1  
Well, grep will also try search for the string in a binary file, and report it if it matches: Binary file file.jpg matches –  January Oct 9 '12 at 8:49
    
but it may take a long time which is unnecessary –  Anwar Shah Oct 9 '12 at 8:51
    
However, formally there is no difference between binary and ASCII files on a POSIX system. Therefore, I don't see why grepping "binary" files should take more time than equally large text files. Unless you completely want to avoid grepping binary files (yes, it can be useful). –  January Oct 9 '12 at 8:54
1  
@January When a binary file is read as text, it often has extremely long "lines" (because a character or character sequence that would be interpreted to designate the end of a line may not appear for a long time, or ever). Depending on the way a text search utility is implemented, this could cause performance problems if each "line" is read fully into memory and then checked to see if it matches the search string (which is a reasonable way for grep to be coded, though I don't know if Ubuntu's grep is written that way). –  Eliah Kagan Oct 9 '12 at 9:30
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.