- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- finding files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 10:56 AM
тАО01-10-2008 10:56 AM
finding files
This should be checked for every hour
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 12:50 PM
тАО01-10-2008 12:50 PM
Re: finding files
ls /mydir/abc* > /dev/null
if [[ $? -eq 0 ]]
then
echo "abc files found - `date`"|mailx -m -s "File Alert" somebody@there.com
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 12:58 PM
тАО01-10-2008 12:58 PM
Re: finding files
the 1 hour requirement means you're going to have to use "touch" to set a dummy file's time to 1 hour before current time, then use "find -newer" to find the files. Once you've got the list you can exclude what you want.
"man touch", "man find" and search HP forum with "find newer" for more info
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 01:41 PM
тАО01-10-2008 01:41 PM
Re: finding files
If you are looking for files modifed in the last hour, use Perl:
# perl -MFile::Find -le 'find(sub{print if -f $_ && -M _ < (1/24) && m/^abc/},"/home/test")'
This finds files in the specified directory that are 1/24 of a day (one hour) or less in age. This age is the *modification* age of the file. There is no such thing as a "creation" timestamp in Unix.
If you would like to use pure shell:
# touch -amt 01101530 /tmp/myref
# find /home/myref -type f -newer /tmp/myref -name "abc*"
Of course, the "problem" in the shell solution is that you have to perform a touch of a reference file to create the one-hour delta everytime you want to search! The Perl solution obviates that.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 03:25 PM
тАО01-10-2008 03:25 PM
Re: finding files
You got nice advice about Perl and
standard grep options.
As always, Unix tools offer such a wide variety of solutions. That is the
power of having freedom to chose the
one that suites you :)
If I understand your request correctly,
you want to EXCLUDE filenames that start
with "abc" string.
If you use GNU grep (much more
powerful that standard grep),
it is very easy. An example (line is
wrapped for readability purpose):
find /home/test -type f ! -name 'abc*' \
-cmin -60 -exec ls -als {} \; 2>/dev/null | \
mailx -s "SUMMARY: New abc files" username
Explanation about "-amin", "-cmin" and
"-mmin" flag arguments:
+n for greater than n
-n for less than n
n for exactly n
So...
"-cmin 60" means status changed EXACTLY
60 minutes ago
"-cmin -60" means status changed LESS THAN
60 minutes ago
"-cmin 60" means status changed MORE THAN
60 minutes ago
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 03:27 PM
тАО01-10-2008 03:27 PM
Re: finding files
You got nice advice about Perl and
standard find options.
As always, Unix tools offer such a wide variety of solutions. That is the
power of having freedom to chose the
one that suites you :)
If I understand your request correctly,
you want to EXCLUDE filenames that start
with "abc" string.
If you use GNU find (much more
powerful that standard grep),
it is very easy. An example (line is
wrapped for readability purpose):
find /home/test -type f ! -name 'abc*' \
-cmin -60 -exec ls -als {} \; 2>/dev/null | \
mailx -s "SUMMARY: New abc files" username
Explanation about "-amin", "-cmin" and
"-mmin" flag arguments:
+n for greater than n
-n for less than n
n for exactly n
So...
"-cmin 60" means status changed EXACTLY
60 minutes ago
"-cmin -60" means status changed LESS THAN
60 minutes ago
"-cmin 60" means status changed MORE THAN
60 minutes ago
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 03:54 PM
тАО01-10-2008 03:54 PM
Re: finding files
Oops, you want to EXCLUDE files beginning with the string "abc". Hence in either the Perl or the shell, we negate (!) the name matching:
# perl -MFile::Find -le 'find(sub{print if -f $_ && -M _ < (1/24) && $_ !~m/^abc/},"/home/test")'
# find /home/test -type f -newer /tmp/myref ! -name "abc*"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 04:43 PM
тАО01-10-2008 04:43 PM
Re: finding files
Like James, I also made a typing error :)
I must be getting old and absent minded...
This is correct explanation:
"-cmin +60" means status changed MORE THAN
60 minutes ago
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2008 07:11 AM
тАО01-11-2008 07:11 AM
Re: finding files
I will check it.