- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find: how to find files created from 4 to 2 days a...
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
Forums
Discussions
Discussions
Discussions
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
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
03-14-2002 04:26 AM
03-14-2002 04:26 AM
I want to find all files created 1,2 and 3 days ago, but not (24h * 1), (24h * 2), (24h * 3) ago from now.
Simply all files created yesterday, 1 day befor yesterday and 2 days before yesterday.
I have to use standard find (HP-UX 11.00)(not GNU)!
How can I use -mtime switch ?
Example:
========
My files:
-rw------- 1 user user 123456 Mar 10 00:01 1file
-rw------- 1 user user 123456 Mar 10 16:00 2file
-rw------- 1 user user 123456 Mar 11 06:00 3file
-rw------- 1 user user 123456 Mar 11 12:00 4file
-rw------- 1 user user 123456 Mar 12 06:00 5file
-rw------- 1 user user 123456 Mar 12 12:00 6file
-rw------- 1 user user 123456 Mar 13 06:00 7file
-rw------- 1 user user 123456 Mar 13 16:00 8file
-rw------- 1 user user 123456 Mar 13 23:30 9file
When I start find statament (find . -mtime -3 -mtime +0 -exec ls -la {} \;) at 13:30 I will get:
-rw------- 1 user user 123456 Mar 11 12:00 4file
-rw------- 1 user user 123456 Mar 12 06:00 5file
-rw------- 1 user user 123456 Mar 12 12:00 6file
-rw------- 1 user user 123456 Mar 13 06:00 7file
but I want:
-rw------- 1 user user 123456 Mar 11 06:00 3file
-rw------- 1 user user 123456 Mar 11 12:00 4file
-rw------- 1 user user 123456 Mar 12 06:00 5file
-rw------- 1 user user 123456 Mar 12 12:00 6file
-rw------- 1 user user 123456 Mar 13 06:00 7file
-rw------- 1 user user 123456 Mar 13 16:00 8file
-rw------- 1 user user 123456 Mar 13 23:30 9file
KRI
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 04:41 AM
03-14-2002 04:41 AM
Re: find: how to find files created from 4 to 2 days ago
how about using a reference file?
touch time_you_want file_name
find /path -newer file_name
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 04:50 AM
03-14-2002 04:50 AM
Re: find: how to find files created from 4 to 2 days ago
I can not use touch to change files mtime because this files are an archive and can not be changed.
In the directory I have over than 100000 files and I must find some of them.
KRI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 04:51 AM
03-14-2002 04:51 AM
Re: find: how to find files created from 4 to 2 days ago
touch 0203100000 file ( this will create file with data 10 Mar 2002 at 00:00 )
find DIR -newer file -exec ll {} \; > file2
This will move the files newer than file in file2
Now you have to find files listed in file2 older than yesterday
cat file2 | grep -v 13 | grep -v 14
Ciao
Federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 04:58 AM
03-14-2002 04:58 AM
Re: find: how to find files created from 4 to 2 days ago
the touch- command is only used to create a reference- file!
Look at the format in the posting of Frederico.
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 05:08 AM
03-14-2002 05:08 AM
Re: find: how to find files created from 4 to 2 days ago
I realy have over then 100000 in one directory and I want find same of them.
Some files was created yasterday, some week ago, some 2 weeks ago, some 2 years ago etc.
Now I must find files created for example from 01-01-2000 do 30-06-2000. How can I touch files when I do not know this files are, and what are named etc.
Hello from Poland
KRI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 05:19 AM
03-14-2002 05:19 AM
Re: find: how to find files created from 4 to 2 days ago
once again, you use the file, which you create with the touch- command only as ONE time- reference- file.
pwd
--> where_ever_you_want
touch 0203100000 file
the next is one command line:
find /archive -newer /where_ever_you_want/file -exec ll {}; #end of command
Of course, you can pipe this or redirect into a file and work with it, perhaps to filter something out with cut or grep commands.
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 05:23 AM
03-14-2002 05:23 AM
Re: find: how to find files created from 4 to 2 days ago
# pfind .
./3file
./4file
./5file
./6file
./7file
./8file
./9file
# cat pfind
#!/opt/perl/bin/perl
use File::Find;
$^T -= $^T % 86400;
find (sub { -M $_ > 0 && -M _ <= 2 and print "$File::Find::name\n"; }, @ARGV);
#
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 05:26 AM
03-14-2002 05:26 AM
Re: find: how to find files created from 4 to 2 days ago
Yes, now I understud !
I very tired ... sory.
But I need -older switch too :-).
I must find file created from A-date to B-date.
-newer switch is good to tell find about A-date.
What about B-date ?
KRI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 05:36 AM
03-14-2002 05:36 AM
Re: find: how to find files created from 4 to 2 days ago
With the -newer option you get everything, from a specified time on. Therefor i mentioned, that you could now do something with the output of this command. I would direct it into a file first. (don't know how much matches you will have.) Then you simply have to make your match more precisely. For example you could do a command:
grep -v dates_you_don't_want /rederected_file
this would give you the output you want. Even better work would this with awk.
Allways stay on the bright side of life!
Peter
p.s. go to bed if possible and retry tomorrow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 05:57 AM
03-14-2002 05:57 AM
Re: find: how to find files created from 4 to 2 days ago
1. Perl
I do not have /opt/perl/bin/perl
but /usr/contrib/bin/perl, but not run corectly.
pfind[3]: use: not found
pfind[5]: $^T: not found
pfind[5]: syntax error at line 6 : `(' unexpected
2. Peter !
I have my project ready in 99% and if I'll want to change this, I must start from begin. Ohhh ! I'm in trouble now !
KRI
P.S.
Sleep - dream :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 06:14 AM
03-14-2002 06:14 AM
SolutionYou could create 2 flag files, one for the "before" date and one for the "since" date:
# touch 200203031000 file1
# touch 200203071000 file2
# ls -l file*
-rw-rw-r-- 1 root sys 0 Mar 3 10:00 file1
-rw-rw-r-- 1 root sys 0 Mar 7 10:00 file2
# find /tmp -newer file1 -a ! -newer file2 | xargs ls -l
-rw-rw-r-- 1 wakefir users 89 Mar 4 16:36 /tmp/60days.sh
-rwxr-xr-x 1 root sys 108 Mar 6 16:27 /tmp/checkjoin
-rw-r--r-- 1 root sys 346 Mar 7 06:26 /tmp/dirchk.log.14484
-rw-r--r-- 1 root sys 346 Mar 5 06:45 /tmp/dirchk.log.170
-rw-r--r-- 1 root sys 346 Mar 4 06:29 /tmp/dirchk.log.26323
-rw-r--r-- 1 root sys 346 Mar 6 06:26 /tmp/dirchk.log.7540
-rwxr-xr-x 1 root sys 260 Mar 7 09:59 /tmp/f.sh
-rwxr-xr-x 1 root sys 18 Mar 5 16:12 /tmp/get_in.sh
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 06:35 AM
03-14-2002 06:35 AM
Re: find: how to find files created from 4 to 2 days ago
As of Sep 2001 (application CD 5012-7954) perl-5.6.1 (the latest stable release) is available for free.
Please install that version in order to enjoy it's power.
You can get precompiled versions for both 10.20 and 11.00 on the HP-UX software mirrors, for exaple from here: http://hpux.tn.tudelft.nl/hppd/hpux/Languages/perl-5.6.1/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2002 06:36 AM
03-14-2002 06:36 AM
Re: find: how to find files created from 4 to 2 days ago
Simple things are superb !
KRI