2

I have a hard drive filled with files, and I need to find a specific file without knowing its name. All I know is that the file contains a list of email addresses. Is there any way I can locate it?

2 Answers2

1

Via find and grep

I don't use grep -r because in POSIX systems, you don't find -r parameter for grep.

find . -type f -print0 | xargs -0 grep 'your_email_address' {} \;

Or

find . -type f -exec grep -l -- 'your_email_address' +

There are many possibilities.

The command finds all files in the current folder and subfolders and passes the result to grep. grep finds the files with your_email_address.

A.B.
  • 90,397
1

You can try using grep -r:

Here is an example where I grepped for the text "listen_address" in any file from my home dir:

aploetz@dockingBay94:~$ grep -r listen_address *
Documents/stackOverFlowAnswer_connectToCassandra.txt~:If you are connecting to Cassandra from your localhost only (a sandbox machine), then you can set the `listen_address` in your cassandra.yaml:
Documents/stackOverFlowAnswer_connectToCassandra.txt~:    listen_address: localhost
Documents/stackOverFlowAnswer_connectToCassandra.txt:If you are connecting to Cassandra from your localhost only (a sandbox machine), then you can set the `listen_address` in your cassandra.yaml:
Documents/stackOverFlowAnswer_connectToCassandra.txt:    listen_address: localhost
Documents/stackOverFlowAnswer_connectToCassandra.txt:    listen_address: dockingBay94
Ubuntu One/cassandraClass/cassandra.yaml:listen_address: $(HOSTNAME)
Ubuntu One/cassandraClass/cassandra.yaml:# Leaving this blank will set it to the same value as listen_address
Aaron
  • 6,714