search and find


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search and find
# 1  
Old 02-23-2009
Tools search and find

Good Morning Team,

Looking for some help on shell scripting please

I need to search recursivly through a tree of directorys for a file I will input and text I am looking for, so the input would look like this:

./search.sh /var/www iframe

And display the path and file name if found..

Can anyone give any ideas please..

All the best from Alan
# 2  
Old 02-23-2009
Why don't you use the find command? Have a read the man page for the options.

Regards
# 3  
Old 02-23-2009
Hi there,

Yes I did use find command but it needs a combintation of find and grep through about 100,000 files.
And that is where I get stuck

All the best from Alan
# 4  
Old 02-23-2009
use find command. the simplest syntax iss

find . -name "*.*"

if you want to find the text inside the files

find . -name "*.*" | xargs grep -i "txt to search for"

change "." to any base directory you want to start search. replace "*.*" to any specific patter to search for pattern.
# 5  
Old 02-23-2009
Code:
find /var/www -name iframe -print

Whats the probelem? Performance?
# 6  
Old 02-23-2009
Computer

Quote:
Originally Posted by frijofranco
use find command. the simplest syntax iss

find . -name "*.*"

if you want to find the text inside the files

find . -name "*.*" | xargs grep -i "txt to search for"

change "." to any base directory you want to start search. replace "*.*" to any specific patter to search for pattern.
Thank you very much that worked perfect saved a lot of time and trouble, and thanks to everyone else for there suggestions

Best regards from Alan
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Busybox search replacement for find

Hi, I am looking for a solution to find files in a folder and subfolders. Those files should be moved (some with spaces) when they were between 2015 Feb. 03 and 2014 Nov. 24. find . -type f -newermt "2010-01-01" ! -newermt "2010-06-01" I am working on a QNAP with a small busybox.... (2 Replies)
Discussion started by: krischeu
2 Replies

2. UNIX for Dummies Questions & Answers

Use ls or find for search of subdirectories?

(5 Replies)
Discussion started by: jhsinger
5 Replies

3. Shell Programming and Scripting

Search: find current line, then search back

Hello. I want to find a line that has "new = 0" in it, then search back based on field $4 () in the current line, and find the first line that has field $4 and "last fetch" Grep or Awk preferred. Here is what the data looks like: 2013-12-12 12:10:30,117 TRACE last fetch: Thu Dec 12... (7 Replies)
Discussion started by: JimBurns
7 Replies

4. UNIX for Dummies Questions & Answers

find Search - Find files not matching a pattern

Hello all, this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction. My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies

5. UNIX for Advanced & Expert Users

Recursive directory search using ls instead of find

I was working on a shell script and found that the find command took too long, especially when I had to execute it multiple times. After some thought and research I came up with two functions. fileScan() filescan will cd into a directory and perform any operations you would like from within... (8 Replies)
Discussion started by: newreverie
8 Replies

6. Shell Programming and Scripting

How to search for a file without using find or which?

Hello, I am a newbie to Unix shell script writing. I have to write a Korn or Bash shell script to search for a file, where some file named <filename> is given at the prompt. So let's say the script command will be called locate_file. Then one could enter locate_file filename. The... (1 Reply)
Discussion started by: TPaine_4liberty
1 Replies

7. Shell Programming and Scripting

find negative search

I have a config file as below. This file is delimited by ; First field is the starting directory for find command. Second field is -mtime value for the find command. Third field is combination of folder and file delimited by | /home/export/temp;+30;file1|dir1|file2... (3 Replies)
Discussion started by: cmoulee
3 Replies

8. UNIX for Advanced & Expert Users

to search files using find

hi friens, :) if ther are files named .c++,.C++,.cpp,.Cpp,.CPp,.cPP,.CpP,.cpP,.c,.C wat is the pattern for finding them :confused: (0 Replies)
Discussion started by: arunsubbhian
0 Replies

9. Shell Programming and Scripting

To search for a text in until i find that

In a CSH, i need to write a loop to seach continuously for text "Started" and then only exit from the loop when ever if finds that. Can someone please suggest how we can write this Thanks, Sateesh (3 Replies)
Discussion started by: kotasateesh
3 Replies
Login or Register to Ask a Question