Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to search a file

Posted on 2002-06-18
8
Medium Priority
?
306 Views
Last Modified: 2010-04-21
I would like to search a file from home directoty.
How to do it. What is the command for that.
Please help!!!

thanks,

hmk
0
Comment
Question by:hmk
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 7089284
assume that you are in you home dir.
use:

find . -name yourfilename -print

0
 
LVL 21

Expert Comment

by:tfewster
ID: 7089301
To locate a file in your home directory:
find ~ -name "*partialfilename*" -print

To find a string within a file somewhere in your home directory tree is more awkward, but:
find ~ -type f -print -exec grep searchstring {} \;
should get you started.
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7089321
Ah, yuzh is on the case ; /me goes back to sleep ;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:hmk
ID: 7089643
Is it possible to find out the file without knowing where it is ? And also i want path of the file too.
Please help

hmk
0
 
LVL 38

Expert Comment

by:yuzh
ID: 7089882
ok you want the full path to the file, lets assume your home dir is: /home/hmk (some sys adm, use /export/home/hmk,
cd ~, and type in: pwd, to find out)
use:

find /home/hmk -name yourfilename -print

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7089978
find ~ -name yourfile -ls
0
 

Author Comment

by:hmk
ID: 7089984
I got following error when i did this.

$ find /home/hmk -name Opt* -print    
find: missing conjunction

hmk
0
 
LVL 21

Accepted Solution

by:
tfewster earned 150 total points
ID: 7090001
If using wildcards in the name parameter, they must be enclosed in double quotes
$ find /home/hmk -name "Opt*" -print    
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question