LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I have forget the name of the file to be find (https://www.linuxquestions.org/questions/linux-newbie-8/i-have-forget-the-name-of-the-file-to-be-find-568367/)

chnlinux 07-11-2007 06:46 AM

I have forget the name of the file to be find
 
Hi ,

I have forget the name of the file to be find.Which command should i use to find the name of the file which contains numbers in the file

Thanks&Regards,
Sathish

chrism01 07-11-2007 07:19 AM

do you mean numbers in the filename, or numbers in the file contents?
1. ls|grep [0-9]
2. cat *|grep [0-9]

these are very simple examples, you can come up with more sophisticated methods

theYinYeti 07-11-2007 07:37 AM

I'm not sure of what you want to achieve. If I understand correctly, you have a known number, say 13579, and you want to find the file that contains this number.

First, let me say your search may find "false positives", ie. files that contains this number but are not the one you're looking for; so you may have to find your file among those returned by the search.

The easiest way to find this file, provided it is in a suitable directory, is to use a desktop search tool like Beagle or Google Desktop.

Else you may want to try this command (as root):
Code:

find /bin /boot /etc /home /lib /media /opt /root /sbin /usr /var -type f -exec grep -l 13579 '{}' \; 2>/dev/null
- Although the command is long, it is easier than dealing with find's -prune option, in my opinion.
- I don't use grep -r because recursive grep gets easily lost with links, especially in /etc.

Or if you know that the file is in /home for example:
Code:

grep -rl 13579 /home 2>/dev/null
Yves.


All times are GMT -5. The time now is 01:35 PM.