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
Solved

how to search a file

Posted on 2002-06-18
8
279 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 20

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 20

Expert Comment

by:tfewster
ID: 7089321
Ah, yuzh is on the case ; /me goes back to sleep ;-)
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 20

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
llcommand 6 98
How to check files recursively from multiple directories and get latest file in bash script 6 107
unix in java example 9 70
Linux hostname change 2 83
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

856 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