Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

operations

Status
Not open for further replies.
Aug 3, 2001
29
US
I am checking files and time stamps to determine older than current time. I am not sure on the format ???

-ot is older than

but I tried using -le less than or equal to , is this only for mathematics ????


Thanks for any help.

Maybe you can point me to a site that has these definitions. I just don't have them available


Len
 
There's a site with all AIX manual pages - if that helps
the Man pages for find :
find Command
Purpose
Finds files with a matching expression.

Syntax
find Path ... [ Expression ]


Description
The find command recursively searches the directory tree for each specified Path parameter, seeking files that match a Boolean expression written using the terms given in the following text. When the find command is recursively descending directory structures, it will not descend into directories that are symbolically linked into the current hierarchy. The output from the find command depends on the terms specified by the Expression parameter.

The find command does not support the 4.3 BSD fast find syntax.

-size Number Evaluates to the value True if the file is the specified Number of blocks long (512 bytes per block).
The file size is rounded up to the nearest block for comparison.

-size Numberc Evaluates to the value True if the file is exactly the specified Number of bytes long.
Adding c to the end of the Number variable indicates that the size of the file is measured in individual bytes not blocks.

-atime Number Evaluates to the value True if the file has been accessed in Number-1 to Number multiples of 24 hours.
For example, -atime 2 is true if the file has been accessed within 24 to 48 hours.

-ctime Number Evaluates to the value True if
the file i-node (status information) has been changed in the specified number of 24-hour periods.

-mtime Number Evaluates to the value True if the file has been modified in
Number-1 to Number multiples of 24 hours.

Examples
To list all files in the file system with a given base file name, enter:
find / -name .profile -print
This searches the entire file system and writes the complete path names of all files named .profile. The / (slash) tells the find command to search the root directory and all of its subdirectories. In order not to waste time, it is best to limit the search by specifying the directories where you think the files might be.

To list all files in the current directory that have been changed during the current 24-hour period, enter:
find . -ctime 1 -print

To search for regular files with multiple links, enter:
find . -type f -links +1 -print
This lists the names of the ordinary files (-type f ) that have more than one link (-links +1 ).
Note: Every directory has at least two links: the entry in its parent directory and its own . (dot) entry. The ln command explains multiple file links.

To find all accessible files whose path name contains find, enter:
find . -name '*find*' -print

To remove all files named a.out or *.o that have not been accessed for a week and that are not mounted using nfs, enter:
find / \( -name a.out -o -name '*.o' \) -atime +7 ! -fstype nfs -exec \ rm {} \;
Note: The number used within the -atime expression is +7 . This is the correct entry if you want the command to act on files not accessed for more than a week (seven 24-hour periods).

To print the path names of all files in or below the current directory, except the directories named SCCS or files in the SCCS directories, enter:
find . -name SCCS -prune -o -print

To print the path names of all files in or below the current directory, including the names of SCCS directories, enter:
find . -print -name SCCS -prune

To search for all files that are exactly 414 bytes long, enter:
find . -size 414c -print

To find and remove every file in your home directory with the .c suffix, enter:
find /u/arnold -name "*.c" -exec rm {} ;
Every time the find command identifies a file with the .c suffix, the rm command deletes that file. The rm command is the only parameter specified for the -exec expression. The {} (braces) represent the current path name.

HTH ;-)
Dickie Bird
db@dickiebird.freeserve.co.uk
 
Thanks for the lead to AIX manual page.

I'm not sure I understand the detailed find command but I'll look into it. Thanks for the assistance.

If I am looking in a directory and have files that I want to accumulate and send on that fall in times that I look into the directory ? every 5 minutes is the -ot and -le usage proper or is there another way to build up a list of files between this time and the next time I look into the directory ????

Thanks again,

Len
 
-ot ????? older than ????
In scripts you can use -gt -lt -eq -ge and -ne
(unless I'm out of date)
Thread822-355004 will give you enough pointers, I think.
;-) Dickie Bird
db@dickiebird.freeserve.co.uk
 
I am clipping the subroutine from my script.
This works but only backwards from the timestamp to the beginning of the filelist.

I have tried to use -le or -gt but I'm not sure I am doing it correctly ???

dir=`ls $FROMDIR/*`
for file in $dir; do
if [ $file -ot $TIMESTAMP ]; then
zcat $file >> $FILELIST
fi
done

In this application I am building a list of compressed files from an hourly directory that will be uncompressed and then data is pulled out for another system.
The above works but when I put in any other (-lt -le ,,,,) my list is empty.

Thanks for all your assistance

Len
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top