02-26-2009
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?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
I can't manage to list all files that are not directories from current directory. (2 Replies)
Discussion started by: beni22sof
2 Replies
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. HP-UX
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
9. Shell Programming and Scripting
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
10. UNIX for Advanced & Expert Users
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
VIDIR(1) VIDIR(1)
NAME
vidir - edit directory
SYNOPSIS
vidir [--verbose] [directory|file|-] ...
DESCRIPTION
vidir allows editing of the contents of a directory in a text editor. If no directory is specified, the current directory is edited.
When editing a directory, each item in the directory will appear on its own numbered line. These numbers are how vidir keeps track of what
items are changed. Delete lines to remove files from the directory, or edit filenames to rename files. You can also switch pairs of numbers
to swap filenames.
Note that if "-" is specified as the directory to edit, it reads a list of filenames from stdin and displays those for editing.
Alternatively, a list of files can be specified on the command line.
OPTIONS
-v, --verbose
Verbosely display the actions taken by the program.
EXAMPLES
vidir
vidir *.jpeg
Typical uses.
find | vidir -
Edit subdirectory contents too. To delete subdirectories, delete all their contents and the subdirectory itself in the editor.
find -type f | vidir -
Edit all files under the current directory and subdirectories.
ENVIRONMENT VARIABLES
EDITOR
Editor to use.
VISUAL
Also supported to determine what editor to use.
AUTHOR
Copyright 2006 by Joey Hess <joey@kitenet.net>
Licensed under the GNU GPL.
moreutils 2010-04-28 VIDIR(1)