command to find files

Hi folks,

What command/commands I have to run to find the files including their folder/subfolder which contain word-a, word-b etc.

e.g. I expect to find the names of the files including their folders which contain "domain", "subdomain/sub domain", "free domain". etc.

TIA

B.R.
satimis

 ls -R | grep -E 'word-[ab]'

?

Hi,

Whether run;

$ ls -R | grep -E 'domain subdomain sub domain free domain' /path/to/database

TIA

B.R.
satimis

This should work,

find . -path "*domain*" 2> /dev/null

Will find files that do have 'domain' in the filename, and will find files that don't have 'domain' in the filename, but exist in a directory with 'domain' in the dirname.

You shouldn't need to search for "subdomain/sub domain", "free domain". etc. because the original search for 'domain' will find them all.

In case the previous post is not right, my interpretation is:

find . -name "*domain*" -print

Hi,

I expect finding the files having "domain" in the content, not the filename. Thanks

B.R.
satimis

Really needs an example.

This is what I think you mean (find the names of files which contain the string "domain" in the content).

find . -type f -exec grep -l "domain" {} \;

Hi,

I have files on /path/to/directories having contents on lists of websites offering free domain and subdomain. I also have files having contents about registration to some websites.

I tried

find /path/to/directories -type f -exec grep -l "domain" {} \;

I couldn't find them.

B.R.
satimis

Please post the exact command you typed, also, the contents of the file you expected to match.

it might also be a permissions problem. did you have permissions to look in these dirs?

$ find /home/satimis/Documents_from_2001_2010/ -type f -exec grep -l "domain" {} \;

There are lot of files generated including .js/html/htm etc. Those files which I want to find are in .txt and .doc format. I think it would be better to narrow down the search. I have permission reading those directories. Besides I also tried the command with "sudo" added.

satimis

Naturally. We couldn't help you with this until you actually told us.

find /home/satimis/Documents_from_2001_2010/ -type f '(' -name '*.txt' -o -name '*.doc' ')' -exec grep -l "domain" {} \;

added where?

Also:

There may be a reason it's not matching.

Hi,

Thanks for your assistance.

The command works. However it generates lot of files.

Years ago, I registered several subdomains with some websites. Because of inactive I suppos they have been deleted. I need to re-register them. Unfortunately I can't recall those websites nor the name of the company. What I can remember is all subdomain starting with "satimis" e.g. satimis.aaa.com or satimis.bbb.net or satimis.ccc.org etc. If I expect to narrow down the searching please advise what shall I add to your command. Thanks

At the beginning of your command. Because some files may be owned by root.

B.R.
satimis