Reputation: 6350
I have to check the user and owner of that file which is modified in last 24 hours .I am not able to understand how could i get the file which is modified in last 24 hour
ls -lrt /dirpath | grep 'Util'
Output of this command is :
-rw-r--r-- 1 user user 186 Apr 11 08:05 Util-04-11.log.gz
-rw-r--r-- 1 user user 185 Apr 12 08:05 Util-04-12.log.gz
-rw-r--r-- 1 user user 186 Apr 13 08:05 Util-04-13.log.gz
-rw-r--r-- 1 user user 186 Apr 14 08:05 Util-04-14.log.gz
-rw-r--r-- 1 user user 278 Apr 20 08:05 Util-04-20.log
Now i want to check user and owner of file which is modified in last 24 hours.How we can do this in unix.
Upvotes: 0
Views: 459
Reputation: 8395
You could use the find
command specifying creation time is less than one day (-ctime 0
), then use xargs
to perform your ls
:
find /dirpath -name "*Util*" -ctime 0 -type f |xargs ls -lrt
Hope it helps.
Upvotes: 0
Reputation: 932
You can use find
to filter files with corresponding modified date.
From the man page:
find $HOME -mtime 0
Search for files in your home directory which have been modified in the last twenty-four hours. This command works this way because the time since each file was last modified is divided by 24 hours and any remainder is discarded. That means that to match -mtime 0, a file will have to have a modification in the past which is less than 24 hours ago.
With that in mind you can use the -exec
option to build the following command
find /dirpath -mtime 0 -exec stat -c "%n %U %G" '{}' \;
Upvotes: 1