Finding files in current directory when 100,000's files in current directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding files in current directory when 100,000's files in current directory
# 1  
Old 02-26-2009
Power Finding files in current directory when 100,000's files in current directory

Hi All

I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age.

I have experimented with the find command in unix but it also searches all sub directories. I have found references on internet that specify maxdepth/depth to limit search to current directory but the flavour of unix I am using does not have the maxdepth flag, I have read the man pages of find command and cannot find any way to limit search to current directory.

Can I use a unix ls command and pipe the output to another built in unix command that can check for age of file(remembering it can handle searching 100,000s of files)?

I seem to be having much issues with this and have not come up with a simple solution.

Can someone give me a sample unix script of what to do?
# 2  
Old 02-26-2009
# 3  
Old 02-26-2009
Do you have the ability to use Perl or Python? You might also want to check to see if your copy of ls has the --full-date flag, which could help if you're doing a shell script.

Also, what version of Unix are you on? Sometimes --max-depth is there, but it's a different flag name.

Try "which perl" and "which python" to see if you have those. You could easily slap together a little script to do this.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

2. Shell Programming and Scripting

Find files only in current directory...not subdirectories

Hi, I have to find files only in the current directory...not in the sub directories. But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help..I tried to use maxdepth..but it is not working in AIX. (2 Replies)
Discussion started by: vsachan
2 Replies

3. HP-UX

How do I include header files outside of my current directory

I am trying to compile a file called PPFormatageMUT.c in which I have included header file which are at some other location but the point is that while compiling the file, it is throwing error saying that error : no such file or directory source code location:... (1 Reply)
Discussion started by: ezee
1 Replies

4. Shell Programming and Scripting

Find files ONLY in current directory

Hello all, I am having a hard type in figuring out how to only gather certain files in the current directory without exploring its subdirectories. I tried: find . -name "*.ksh" -prune this also returns ksh files from lower subdirectories. I also tried find . -ls -name "*.ksh" This also... (8 Replies)
Discussion started by: gio001
8 Replies

5. Shell Programming and Scripting

How to strip ^M at end of each files for all files found in current directory

I am trying to use a loop to strip of the funny character ^M at the end of all lines in each file found in current directory and I have used the following in a script: find . -type f -name '*.txt' | while read file do echo "stripping ^M from ..." ex - "$file" > $tempfile %s/^M//g wq! # mv... (4 Replies)
Discussion started by: bisip99
4 Replies

6. Shell Programming and Scripting

mget * (obtein files from current directory but not the files form sub-directories)

Hello, Using the instruction mget (within ftp) and with "Interactive mode off", I want to get all files from directory (DirAA), but not the files in sub-directories. The files names don't follow any defined rule, so they can be just letters without (.) period Directory structure example: ... (0 Replies)
Discussion started by: Peter321
0 Replies

7. UNIX for Dummies Questions & Answers

List files that are not directories from current directory

I can't manage to list all files that are not directories from current directory. (2 Replies)
Discussion started by: beni22sof
2 Replies

8. Shell Programming and Scripting

finding 0 byte files in current directory only

Hi Gurus, I have a directory A, which has some 0 byte files in it. This directory also has a subdirectory B which also has some 0 byte files in it. The problem: I only need to find out the names of the 0 byte files in the directory A. I'm using the following command find . -name *.zip... (6 Replies)
Discussion started by: ramky79
6 Replies

9. Shell Programming and Scripting

Searching for files over 30 days old in current directory

May be a simple question for experts here.... I need to get the list of files older than 30 days in the current folder. I tried "find", but it searches recursively in all the sub directories. Can I restrict the recursive search and extract the files only from current directory ? (18 Replies)
Discussion started by: cxredd4
18 Replies

10. Shell Programming and Scripting

Need quick help with diff files in current directory!!!

i have a problem that needs to be solved with CSH , SED or AWK as soon as possible. I need to write a program which creates a directory called backup (if it does not exist). The program then compares all the ordinary files in the current directory and if two files are identical, it moves one of... (1 Reply)
Discussion started by: tkwai
1 Replies
Login or Register to Ask a Question