Solved

how to search a file

Posted on 2002-06-18
8
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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 50 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

626 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