Hello All.
How do I find the list of all files modified since yesterday? I know one option would be find / -mtime N But this is a bit confusing. Should N be 1 or -1? Is there a better way? I don't have any IDS like tripwire installed on my servers.
I have five IBM servers running RHEL 3 and one running AIX.
Regards, NMK.
On Saturday 07 January 2006 02:36 PM, Derwyn Dpenha wrote:
How do I find the list of all files modified since yesterday? I know one option would be
try man ls
ls -t | grep `date` -t sort by modification time
I think Below command will definately work
"ls -lt | grep "your desire date in YY-MM-SS Format"
i.e
hardik@aks:/home/hardik# ls -lt | grep "2006-01-05" drwxr-sr-x 6 hardik hardik 200 2006-01-05 17:42 sandbox drwxr-sr-x 2 hardik hardik 200 2006-01-05 14:40 Attachments -rw-r--r-- 1 hardik hardik 468 2006-01-05 13:16 tai64n
Hardik. -- "Hey, it's fifteen years today since I bought the machine that got Linux Started. January 2nd is a good date." "Linus Trovalds on Relase of 2.6.15"
Sometime on Sat, Jan 07, 2006 at 03:05:40PM +0530, Hardik Dalwadi said:
I think Below command will definately work
"ls -lt | grep "your desire date in YY-MM-SS Format"
hardik@aks:/home/hardik# ls -lt | grep "2006-01-05" drwxr-sr-x 6 hardik hardik 200 2006-01-05 17:42 sandbox drwxr-sr-x 2 hardik hardik 200 2006-01-05 14:40 Attachments -rw-r--r-- 1 hardik hardik 468 2006-01-05 13:16 tai64n
Now its more generic:
$ ls -lt | grep `date -I`
Anurag
On Sat, 2006-01-07 at 15:09, Anurag wrote:
Sometime on Sat, Jan 07, 2006 at 03:05:40PM +0530, Hardik Dalwadi said:
I think Below command will definately work
"ls -lt | grep "your desire date in YY-MM-SS Format"
hardik@aks:/home/hardik# ls -lt | grep "2006-01-05" drwxr-sr-x 6 hardik hardik 200 2006-01-05 17:42 sandbox drwxr-sr-x 2 hardik hardik 200 2006-01-05 14:40 Attachments -rw-r--r-- 1 hardik hardik 468 2006-01-05 13:16 tai64n
Now its more generic:
$ ls -lt | grep `date -I`
ls -lt give the date like this,
[tima@server tima]$ ls -lt total 5412 -rw-r--r-- 1 tima prgrp 1815 Jan 5 22:25 toppy.txt -rw------- 1 tima prgrp 23024 Dec 17 00:09 mbox drwxr-xr-x 2 root root 1024 Mar 14 2005 plugins
So I can't grep for 2006-01-05. Would have to use sed/awk to process the spaces. BTW, find / -mtime -1 should give me files modified since yesterday, right? Or should it be 1 instead or -1?
Regards, NMK.
On Saturday 07 January 2006 04:31 PM, Nadeem M. Khan wrote:
On Sat, 2006-01-07 at 15:09, Anurag wrote:
Sometime on Sat, Jan 07, 2006 at 03:05:40PM +0530, Hardik Dalwadi said:
ls -lt give the date like this,
[tima@server tima]$ ls -lt total 5412 -rw-r--r-- 1 tima prgrp 1815 Jan 5 22:25 toppy.txt -rw------- 1 tima prgrp 23024 Dec 17 00:09 mbox drwxr-xr-x 2 root root 1024 Mar 14 2005 plugins
I am suspecting above things when i have posted my mail. Try below command.
hardik@aks:~$ ls -lt --time-style=long-iso | grep `date -I` -rw-r--r-- 1 hardik hardik 0 2006-01-07 16:44 hello
Hardik. Hey, it's fifteen years today since I bought the machine that got Linux started. January 2nd is a good date. "Linus Trovalds on Relase of 2.6.15"
On Sat, 2006-01-07 at 16:46, Hardik Dalwadi wrote:
On Saturday 07 January 2006 04:31 PM, Nadeem M. Khan wrote:
On Sat, 2006-01-07 at 15:09, Anurag wrote:
Sometime on Sat, Jan 07, 2006 at 03:05:40PM +0530, Hardik Dalwadi said:
ls -lt give the date like this,
[tima@server tima]$ ls -lt total 5412 -rw-r--r-- 1 tima prgrp 1815 Jan 5 22:25 toppy.txt -rw------- 1 tima prgrp 23024 Dec 17 00:09 mbox drwxr-xr-x 2 root root 1024 Mar 14 2005 plugins
I am suspecting above things when i have posted my mail. Try below command.
hardik@aks:~$ ls -lt --time-style=long-iso | grep `date -I` -rw-r--r-- 1 hardik hardik 0 2006-01-07 16:44 hello
Okay that works. Thanks. I have another query. The above method works if the file *content* is modified (with VI or some text editor). It does not work if the *attributes* of the file are changed (eg chmod a+x filename). In this case, the date stamp remains unchanged.
How do I find which files have had their attributes changed since yesterday?
Regards, NMK.
Sometime Today, NMK cobbled together some glyphs to say:
How do I find the list of all files modified since yesterday? I know one option would be find / -mtime N But this is a bit confusing. Should N be 1 or -1? Is there a better way?
N should be 1. This is the best way, it should not be confusing.
Remember that 'difference' can never be negative. The difference between two quantities is always equal to the larger minus the smaller.
find / -mtime 1d would be more explicit.
to everyone else: ls in conjunction with date has the following problems: 1. it does not dive into subdirectories unless recursive is specified 2. it's slower 3. it requires two fork and execs 4. it only works to find files of one specific date, and not files of a given date range or age.
learn to use all the tools you have access to for free.
Philip
On Sat, 2006-01-07 at 18:28, Philip Tellis wrote:
Sometime Today, NMK cobbled together some glyphs to say:
How do I find the list of all files modified since yesterday? I know one option would be find / -mtime N But this is a bit confusing. Should N be 1 or -1? Is there a better way?
N should be 1. This is the best way, it should not be confusing.
Remember that 'difference' can never be negative. The difference between two quantities is always equal to the larger minus the smaller.
find / -mtime 1d would be more explicit.
[root@server root]$ find / -mtime 1d find: invalid argument `1d' to `-mtime'
Simply using 1 and omitting the d works.
[root@server root]# ls -ld `find /root -mtime 1` -rw------- 1 root root 1331010 Jan 5 22:43 /root/evolution/local/Blug-Prog/mbox -rw------- 1 root root 54323 Jan 5 22:44 /root/evolution/local/Blug-Prog/mbox.ev-summary -rw------- 1 root root 102400 Jan 5 22:44 /root/evolution/local/Blug-Prog/mbox.ibex.index -rw------- 1 root root 180492 Jan 5 22:44 /root/evolution/local/Blug-Prog/mbox.ibex.index.data -rw------- 1 root root 211968 Jan 6 15:23 /root/evolution/local/Blug-Tech/mbox.ibex.index -rw------- 1 root root 618544 Jan 6 15:23 /root/evolution/local/Blug-Tech/mbox.ibex.index.data
<output snipped>
But why is it showing files that are modified on 5th Jan, ie day-before-yesterday?
As per the find man page, it should show files modified N*24 hours ago, thats 24 hours ago (6th Jan. to 7th Jan.).
Regards, NMK.