From: Stu on 9 Jul 2010 09:44 I know what the mtime parameter does but can somebody explain what the difference is when the number followed by the parameter is "+" and when it's "-". Ie: #find . -name "*.trc" -mtime -2 -print | wc -l 3 #find . -name "*.trc" -mtime 2 -print | wc -l 0 There is obvious a difference since I am getting back a different number, but I am not sure what the difference is. thanks to all who answer in advance
From: steven_nospam at Yahoo! Canada on 9 Jul 2010 10:06 On Jul 9, 9:44 am, Stu <beefstu...(a)hotmail.com> wrote: > I know what the mtime parameter does but can somebody explain what > the difference is when the number followed by the parameter is "+" and > when it's "-" > #find . -name "*.trc" -mtime -2 -print | wc -l > 3 > > #find . -name "*.trc" -mtime 2 -print | wc -l > 0 Actually your two examples are not the same as the question you asked, since you did not add the "+" in front of the number on the second one. Here is how it works: List me all the files that were modified within the last two 24 hour periods. # find . -mtime -2 -ls List me all the files that were modified beyond the last two 24 hour periods. # find . -mtime +2 -ls List me all the files that were modified during the second 24 hour period (in other words during the 24hr period from two days ago) # find . -mtime 2 -ls You can test this out by doing the following. Create a temporary directory. Inside the directory, create three sample files using the "touch -t" command. touch -t 201007011212 SAMPLE_JULY01 touch -t 201006201212 SAMPLE_JUNE20 touch -t 201007081212 SAMPLE_JULY09 Now use the find command with an appropriate value (for example: "-10", "+10", or just "9" if doing it on July 9) You should be able to see what exactly it picks up. SteveN
From: Janis Papanagnou on 9 Jul 2010 10:06 Stu schrieb: > I know what the mtime parameter does but can somebody explain what > the > difference is when the number followed by the parameter is "+" and > when it's > "-". The command find and it's parameters is described in the man page. I thought you should already know how to look that up. And, BTW, "2" is not "+2"; it's apparently depending on the context. > > Ie: > > #find . -name "*.trc" -mtime -2 -print | wc -l > 3 > > #find . -name "*.trc" -mtime 2 -print | wc -l > 0 > > There is obvious a difference since I am getting back a different > number, but I am > not sure what the difference is. > > thanks to all who answer in advance
From: Stu on 9 Jul 2010 16:27 On Jul 9, 10:06 am, Janis Papanagnou <janis_papanag...(a)hotmail.com> wrote: > Stu schrieb: > > > I know what the mtime parameter does but can somebody explain what > > the > > difference is when the number followed by the parameter is "+" and > > when it's > > "-". > > The command find and it's parameters is described in the man page. > I thought you should already know how to look that up. > > And, BTW, "2" is not "+2"; it's apparently depending on the context. > > > > > > > Ie: > > > #find . -name "*.trc" -mtime -2 -print | wc -l > > 3 > > > #find . -name "*.trc" -mtime 2 -print | wc -l > > 0 > > > There is obvious a difference since I am getting back a different > > number, but I am > > not sure what the difference is. > > > thanks to all who answer in advance- Hide quoted text - > > - Show quoted text - FYI, I always check the man page first before posting, I would not waste people's time. That's why I made the post/ There was not clear definition of what the "-", "+" or no sign before the n paramter actually does. man find on AIX 5.3 box -mtime n Evaluates as True if the file modification time subtracted from the initialization time, divided by 86400 seconds (with any remainder discarded), is n. 86400 seconds is 24 hours. Note: The definition of -mtime has changed to comply with the Single UNIX Specification, Version 3. The previous behavior of -mtime evaluated as True if the file had been modified in n-1 to n multiples of 24 hours. By default, find -mtime works like it did prior to UNIX03. The UNIX03 behavior can be obtained by setting the environment variables XPG_SUS_ENV to ON and XPG_UNIX98 to OFF. I know you been a big help to me before in the past and I do appreciate your vast knowlege of the shell and its commands but sometimes all the answers are not in the documentation.
From: Janis Papanagnou on 9 Jul 2010 21:39 On 09/07/10 22:27, Stu wrote: > On Jul 9, 10:06 am, Janis Papanagnou <janis_papanag...(a)hotmail.com> > wrote: >> Stu schrieb: >> >>> I know what the mtime parameter does but can somebody explain what >>> the >>> difference is when the number followed by the parameter is "+" and >>> when it's >>> "-". >> >> The command find and it's parameters is described in the man page. >> I thought you should already know how to look that up. >> >> And, BTW, "2" is not "+2"; it's apparently depending on the context. >> >> >> >> >> >>> Ie: >> >>> #find . -name "*.trc" -mtime -2 -print | wc -l >>> 3 >> >>> #find . -name "*.trc" -mtime 2 -print | wc -l >>> 0 >> >>> There is obvious a difference since I am getting back a different >>> number, but I am >>> not sure what the difference is. >> >>> thanks to all who answer in advance- Hide quoted text - >> >> - Show quoted text - > > FYI, I always check the man page first before posting, I would not > waste people's time. That's why > I made the post/ > > There was not clear definition of what the "-", "+" or no sign before > the n paramter actually does. > > man find on AIX 5.3 box Thanks for this new information. I cannot tell you whether AIX 5.3 has a SUS standard find(1) or whether it is similar to the one on my Linux box. I suggest to inspect the man docs on the web and the POSIX standard (http://www.opengroup.org/onlinepubs/009695399/utilities/find.html) and check it out whether your find is conformant. The mentioned docs specify what +n, n, and -n does. Janis > > -mtime n > Evaluates as True if the file modification time subtracted > from > the initialization time, divided by 86400 seconds (with > any > remainder discarded), is n. 86400 seconds is 24 hours. > Note: The > definition of -mtime has changed to comply with the Single > UNIX > Specification, Version 3. The previous behavior of -mtime > evaluated as True if the file had been modified in n-1 to > n > multiples of 24 hours. By default, find -mtime works like > it did > prior to UNIX03. The UNIX03 behavior can be obtained by > setting > the environment variables XPG_SUS_ENV to ON and XPG_UNIX98 > to OFF. > > I know you been a big help to me before in the past and I do > appreciate your vast knowlege of the shell > and its commands but sometimes all the answers are not in the > documentation.
|
Next
|
Last
Pages: 1 2 Prev: Team Red Bull Hats ( www.nike-black.com ) Next: I just don't understand find -prune |