Solved

how to search a file

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

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now