LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2007, 05:46 AM   #1
chnlinux
LQ Newbie
 
Registered: Jun 2007
Posts: 28

Rep: Reputation: 15
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
 
Old 07-11-2007, 06:19 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,363

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
 
Old 07-11-2007, 06:37 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't find my mouse, I forget what to do kryptobs2000 Linux - Hardware 2 07-29-2006 07:23 AM
Where can I find the file over mounten file system Wallace740 Linux - Newbie 2 03-30-2005 02:46 AM
Linker problem: can't find a file, but the file exists atlep Programming 5 08-16-2004 06:15 AM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 10:34 PM
where can I find grammar file and lex file of GNU c ? thinks Huiming Linux - Software 1 06-11-2004 07:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration