Find in file. Does this exist under UNIX?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find in file. Does this exist under UNIX?
# 1  
Old 01-19-2006
Find in file. Does this exist under UNIX?

Hello,
I have the following problem. I know there is a file somewhere on a UNIX machine that contains a string, but I don't know where.

With the "grep" command, I can look into a file but only if I'm located in the correct directory.

With the "find" command, I can search across directories but I cannot specify to search within the files for a certain string.

Does there exist a standard UNIX command for looking for a text within a file without knowing the directory in which the file is located?

Thanks
Dominique
# 2  
Old 01-19-2006
Code:
find . -name "*" -exec grep -l "somestring" {} \;

or

Code:
find . -name "*" | xargs grep -l "somestring"

change grep options according to your need
# 3  
Old 01-19-2006
MySQL Thanks

I have tried. It works fine.

Thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Isql and If Exist syntax error in UNIX script

Hello Everyone, Coming again for your help to solve the below error: In a script, i had created a temp table (Temp_table) and loaded the data in it using bcp command (performed successfully) and I wanted to move it to the preferred table (called Main_table) for further use. hence I have added... (7 Replies)
Discussion started by: Suresh
7 Replies

2. Shell Programming and Scripting

Find command when there exist many files

I want to run find and wondering if it struggles when there are many files. I have tried and does not seem to complain. Is this correct? (8 Replies)
Discussion started by: kristinu
8 Replies

3. Shell Programming and Scripting

Find if a directory exist from a list of the path

Hello, i want to script on sh to check from a path if the directory exist and isn't empty. I explain: path is : /aaa/bbb/ccc/ccc_name/ddd/ Where the cccc_name is in a list, so i think it's $1 My command find -name /aaa/bbb/ccc/$1/ddd/ didn't work because my $1 is the same and not... (5 Replies)
Discussion started by: steiner
5 Replies

4. Shell Programming and Scripting

find + move if destination path does not exist

hi frnds, please help ... what will happen with below command if destination path does not exist on the system.... find /var/adm/cft* -mtime +1 -exec mv {} /global/ \ in unix its remove all my files from the system from soruce file ... how is it possbile (1 Reply)
Discussion started by: dodasajan
1 Replies

5. Shell Programming and Scripting

Find out whether files exist.

I have the following data stored in a file. 1 /home/file13 /home/file2 2 /home/file41 /home/file654 3 /home/file61 /home/file45 4 /home/file81 /home/file43 ... I want to print the first column provided the files represented by the second and third column exist. How to do that? (3 Replies)
Discussion started by: kevintse
3 Replies

6. UNIX for Dummies Questions & Answers

How to find if file exist in directory using *

Hi, I know how to use the test command ( ...) to find a single given name file. However, I have a case in which I have a directory with one file and one sub-directory. I know that the file starts with "fub". The command doesn't work if i call the file "fub*" as it doesn't understand I meant a... (2 Replies)
Discussion started by: buj
2 Replies

7. Shell Programming and Scripting

Can I find wether a particular file exist and size greater than zero...help please

Can I find wether a particular file exist and size greater than zero in one line command. similar to this if && something in one if test .... e.g. if 1.) is it possible ? ... if yes how 2.) what would be the return type in case there is success or failure. I mean if both are... (4 Replies)
Discussion started by: guhas
4 Replies

8. UNIX for Advanced & Expert Users

Does UNIX-Chmod in windows exist?

Is there an command in windows to chmod a file to 666 so that when I mount a NAS on solaris, the user can read/write/remove the file from unix server? Traditionally, we invoke ftp from unix to windows, get the file and remove it. With a NAS, can windows chmod the file 666 so that unix can edit... (2 Replies)
Discussion started by: izy100
2 Replies

9. Shell Programming and Scripting

how to find a file in UNIX without find command?

given a start directory,a filename,how to find it? (3 Replies)
Discussion started by: bluo
3 Replies

10. UNIX for Dummies Questions & Answers

Can Unix Co-Exist with Windows 9X on the same System?

Is it possible to install unix on a system which already runs windows 98? (2 Replies)
Discussion started by: ms73eb
2 Replies
Login or Register to Ask a Question