Search file in all directories.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Search file in all directories.
# 1  
Old 05-10-2012
Search file in all directories.

Hi colleagues,

I need to search one file in all dierctories, i have O.S. AIX 5.3, my file began with cc, the others caracters i unknow.

Then i can to search one string in file in all dierctories.

Thank you for advanced.
# 2  
Old 05-10-2012
Code:
 
find /directory/name -type f -name "cc*" 2>/dev/null

# 3  
Old 05-10-2012
If i like search string in all file all directories how to do?

Thank you.
# 4  
Old 05-10-2012
what is mean by all file all directories ?

the given command will search the file from the directory you have given.

if you give as / (root) then it will search from root
# 5  
Old 05-10-2012
Quote:
If i like search string in all file all directories how to do?
On most systems there will be system files and programs starting with the letters cc. You will be best advised to only search user directories where you know that "cc*" can only match text files.

Code:
search="my search string"
find /directory/subdirectory -type f -name "cc*" 2>/dev/null | while read filename
do
           # Search file for string
           grep "${search}" "${filename}"
done

If you need to search system directories the script will need a higher level of sophistication such that it only searches text files.
# 6  
Old 05-11-2012
all file all directories mean search from / open all directories and search in all files the string to search for.
Thank you for you help.
# 7  
Old 05-11-2012
Binary executables are unsuitable for searching for text strings.
Are these files called cc* all owned by one non-root user? i.e. Is there some simple way of avoiding searching through binary executables on your system?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies

2. Shell Programming and Scripting

Search for a file in all directories and place the file in that directory

Hi All, Daily I am getting the updated file. I have to search for this file in all directories and sub directories. If the file existed in a particular directory then move this updated file to that particular directory. If the file is not existed in any of the directories then place this... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies

3. Shell Programming and Scripting

Command to Search a FILE for a STRING in multiple DIRECTORIES

Hi, Can someone please help me with a Command to Search a FILE for a STRING in multiple DIRECTORIES. I am searching for the VIP in HTTPD.CONF in multiple httpd instances. I am using find ./ -name "httpd.conf" | xargs grep 10.22.0.141 cut -d: -f3- | cut -d ' ' -f4 | sort | uniq -c ... (1 Reply)
Discussion started by: crosairs
1 Replies

4. Shell Programming and Scripting

Search for file extensions in the given directories

Hey guys, I'm lost... I need to make a script that will work in this way: ./script.sh -e sh /usr/bin /home/student this script will result in this output: amuFormat.sh /usr/bin gettext.sh /urs/bin perfect.sh /home/student the parameter -e <ext> gives you which... (2 Replies)
Discussion started by: Miki1579
2 Replies

5. Shell Programming and Scripting

PERL or SHELL Scrript to search in Directories by taking line by line from a text file

Unix box server version *********** >uname -r B.11.00 >echo $SHELL /usr/bin/ksh --> in this server, I have the path like /IMbuild/dev/im0serv1 ---> in that directory I have the folders startup(.jsp files nearly 100 jsp's ) and scripts(contains .js files nearly 100 files) ... (9 Replies)
Discussion started by: pasam
9 Replies

6. UNIX and Linux Applications

Perl Script to read an excel file into an array and search in the UNIX directories

Hi, I want the Perl script with versions 5.8.2 and 5.8.5 starting with #!/usr/bin/perl The Perl program should read the excel file or text file line by line and taking into an array and search in the UNIX directories for reference file of .jsp or .js or .xsl with path .The Object names... (2 Replies)
Discussion started by: pasam
2 Replies

7. UNIX for Advanced & Expert Users

word search in multiple directories

need a Command in UNIX which can find out a word from files in multiple directories e.g. /home contains multiple directories /home/d1 /home/d2 . . . . /home/dn under d1,d2...dn contains multiple files. I need to search a specific word in a files under these multiple... (1 Reply)
Discussion started by: jagkoth
1 Replies

8. Shell Programming and Scripting

How to search through directories and sub dir

Im working on a project that basically imitates the find and whereis commands. The program will take in a file name or regular expression and, starting with the current directory search downwards and match any files with that pattern and prints the path name. I don't understand how to do this... (5 Replies)
Discussion started by: new2C
5 Replies

9. Shell Programming and Scripting

how to search directories

Hello everybody, i'm dummy for unix but i want to learn something. i want to search the working directory and its subdirectories( all ) to find the files which are more than 1024 bytes. So which commands must i learn? Thanks to all. (13 Replies)
Discussion started by: redbeard_06
13 Replies

10. Shell Programming and Scripting

script to search all the directories

Hi there, Is there any command or script to search all the directories for duplicated files? Thanks, Abrahim (3 Replies)
Discussion started by: abk
3 Replies
Login or Register to Ask a Question