Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


using find command only in current directory


 
Thread Tools Search this Thread
# 1  
Data

I am trying to use the find command to find files in the current directory that meet a certain date criteria.

Code:
find . -type -f -mtime +2

However, the above also checks the directories below.
I tried -prune, but that seems to ignore this directory completely.

I read about using -path w/ -prune, but -path is not recognized by my system. Neither is -maxdepth.

Any help would be greatly appreciated!!!!

Thanks,
Julie
# 2  
from the GNU find man page:

Quote:
find - search for files in a directory hierarchy

....... omitted much ........

-maxdepth levels

Descend at most levels (a non-negative integer) levels of directories below the command line arguments.

`-maxdepth 0' means only apply the tests and actions to the command line arguments
# 3  
Thanks for the response.
However, as I mentioned in the initial posting, the -maxdepth does not seem to work on my system. See Below:

Code:
find . -maxdepth 0 -type f -mtime +2

find: 0652-017 -maxdepth is not a valid option.

Other ideas?

Or am I doing something wrong?

When I man find on my system, maxdepth is not shown...I only knew about it from searching around UNIX sites on the net.

Thanks again,
Julie
# 4  
You may not be running GNU utilities. When I work on differnet flavors of UNIX like systems (HP-UX, Solaris) one of the first things I do is set up a development environment to compile GNU utilities for the platforms. The GNU compiler can compile for just about every OS on this planet (and maybe other planets!) You might find it faster to just build a GNU version of find (and then you will be set up for other builds in the future too!!)

The first challenge in this approach is to install a GNU C compiler for your platform. This can be trickly for newbies. However, if you can 'get through it', the rewards are great and very worthwhile.

Perhaps someone else will have a better reply if you state the exact version of find (and the platform).
# 5  
I am working on AIX version 4.3.

I do not know that I can do what you suggested. I work for a very large company...don't know that I can just install things (I've only been here a few weeks).

Will try contacting the UNIX system admins (as soon as someone tells me who they are!) :-)

Thanks!

-Julie
# 6  
Normally large companies will let qualified people set up a server to compile GNU utilities. This is normally done on a non-production development environment. However, if you are not the administrator, they may not like GNU or have other restrictions. These restrictions can really decrease productivity in most shops

However, senior UNIX folks can usually develop a good configuration management plan and show the cost-benefits of building a cross-platform GNU development environment. This is especially true if your shop has many different flavors of UNIX (linux, hpux, aix, etc.)
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
find command to look for current directory only
wtolentino
i have this find command on my script as: for i in `find $vdir -name "$vfile" -mtime +$pday` the problem with this code is that the sub-directories are included on the search. how do i restrict the search to confine only on the current directory and ignore the sub-directories. please advise....... UNIX for Dummies Questions & Answers
7
UNIX for Dummies Questions & Answers
Find files ONLY in current directory
gio001
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...... Shell Programming and Scripting
8
Shell Programming and Scripting
how to stop to current directory using find
james_falco
Hello, I just want to ask the following use of find command: 1. how can I find files only to the current directory? 2. how can I find files to directories and all subdiretories (are this include soft links?) but will not go to other mountpoints that is under that mountpoint. Im combining...... UNIX for Dummies Questions & Answers
1
UNIX for Dummies Questions & Answers
how do i exclude the current directory when using find?
mjays
i want to compile a list of files in all sub directories but exclude the current directory. the closest i could get was to search 'only' the current directory, which is the opposite of what i wanted. find . ! -name . -prune... Shell Programming and Scripting
7
Shell Programming and Scripting
find directory not including current
dangral
Using Solaris 8, I've forgotten how to exclude the current directory in the find results. find . -type d ! -name "*.CAP" I want every directory that does not match the *.CAP pattern, except the current directory.... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers

Featured Tech Videos