How can I sort find output by printing the most 10 latest update files?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
on my linux machines I want to know which file/s are edited recently by users
let say I want to search recursive under /home
the most 10 files that edited recently
how to perform that with find command or other solution?
example of expected output:
27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file
linux find ls sort
migrated from serverfault.com Jul 5 at 9:01
This question came from our site for system and network administrators.
add a comment |Â
up vote
0
down vote
favorite
on my linux machines I want to know which file/s are edited recently by users
let say I want to search recursive under /home
the most 10 files that edited recently
how to perform that with find command or other solution?
example of expected output:
27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file
linux find ls sort
migrated from serverfault.com Jul 5 at 9:01
This question came from our site for system and network administrators.
1
ls -lrt will list in date order use man ls to look at ls options.
â Essex Boy
Jun 27 at 12:55
yes but I want to search recursive
â shalom
Jun 27 at 13:08
find with -mtime
â dmourati
Jul 5 at 3:16
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
on my linux machines I want to know which file/s are edited recently by users
let say I want to search recursive under /home
the most 10 files that edited recently
how to perform that with find command or other solution?
example of expected output:
27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file
linux find ls sort
on my linux machines I want to know which file/s are edited recently by users
let say I want to search recursive under /home
the most 10 files that edited recently
how to perform that with find command or other solution?
example of expected output:
27/6/2018 11:23 /home/my_data/file
27/6/2018 10:21 /home/top/oo/pp/file
27/6/2018 09:23 /home/my_data/GG/file
linux find ls sort
asked Jun 27 at 11:42
shalom
migrated from serverfault.com Jul 5 at 9:01
This question came from our site for system and network administrators.
migrated from serverfault.com Jul 5 at 9:01
This question came from our site for system and network administrators.
1
ls -lrt will list in date order use man ls to look at ls options.
â Essex Boy
Jun 27 at 12:55
yes but I want to search recursive
â shalom
Jun 27 at 13:08
find with -mtime
â dmourati
Jul 5 at 3:16
add a comment |Â
1
ls -lrt will list in date order use man ls to look at ls options.
â Essex Boy
Jun 27 at 12:55
yes but I want to search recursive
â shalom
Jun 27 at 13:08
find with -mtime
â dmourati
Jul 5 at 3:16
1
1
ls -lrt will list in date order use man ls to look at ls options.
â Essex Boy
Jun 27 at 12:55
ls -lrt will list in date order use man ls to look at ls options.
â Essex Boy
Jun 27 at 12:55
yes but I want to search recursive
â shalom
Jun 27 at 13:08
yes but I want to search recursive
â shalom
Jun 27 at 13:08
find with -mtime
â dmourati
Jul 5 at 3:16
find with -mtime
â dmourati
Jul 5 at 3:16
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
To list recursively do
ls -lRrt
If you want to find all the files and list them in date change order
ls -lrt `find . -type f`
There's probably 10,000 ways to do it.
This won't scale if the find output generates so many filenames that you get "argument list too long". Anxargs
variant would help.
â wurtel
Jun 27 at 14:19
add a comment |Â
up vote
2
down vote
Finding the newest 10 files under the current directory:
find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10
Optionally add | cut -f2
to strip the time information.
This uses to -printf
option to find
to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort
. sort -r
does reverse sorting to put the newest (i.e. "biggest") times at the beginning.
This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n
but with to null-terminate the filenames. Then add
--zero-terminated
to the sort options, and put | tr '' 'n'
at the end to convert the null bytes back into newlines.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
To list recursively do
ls -lRrt
If you want to find all the files and list them in date change order
ls -lrt `find . -type f`
There's probably 10,000 ways to do it.
This won't scale if the find output generates so many filenames that you get "argument list too long". Anxargs
variant would help.
â wurtel
Jun 27 at 14:19
add a comment |Â
up vote
2
down vote
accepted
To list recursively do
ls -lRrt
If you want to find all the files and list them in date change order
ls -lrt `find . -type f`
There's probably 10,000 ways to do it.
This won't scale if the find output generates so many filenames that you get "argument list too long". Anxargs
variant would help.
â wurtel
Jun 27 at 14:19
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
To list recursively do
ls -lRrt
If you want to find all the files and list them in date change order
ls -lrt `find . -type f`
There's probably 10,000 ways to do it.
To list recursively do
ls -lRrt
If you want to find all the files and list them in date change order
ls -lrt `find . -type f`
There's probably 10,000 ways to do it.
answered Jun 27 at 13:16
Essex Boy
1363
1363
This won't scale if the find output generates so many filenames that you get "argument list too long". Anxargs
variant would help.
â wurtel
Jun 27 at 14:19
add a comment |Â
This won't scale if the find output generates so many filenames that you get "argument list too long". Anxargs
variant would help.
â wurtel
Jun 27 at 14:19
This won't scale if the find output generates so many filenames that you get "argument list too long". An
xargs
variant would help.â wurtel
Jun 27 at 14:19
This won't scale if the find output generates so many filenames that you get "argument list too long". An
xargs
variant would help.â wurtel
Jun 27 at 14:19
add a comment |Â
up vote
2
down vote
Finding the newest 10 files under the current directory:
find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10
Optionally add | cut -f2
to strip the time information.
This uses to -printf
option to find
to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort
. sort -r
does reverse sorting to put the newest (i.e. "biggest") times at the beginning.
This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n
but with to null-terminate the filenames. Then add
--zero-terminated
to the sort options, and put | tr '' 'n'
at the end to convert the null bytes back into newlines.
add a comment |Â
up vote
2
down vote
Finding the newest 10 files under the current directory:
find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10
Optionally add | cut -f2
to strip the time information.
This uses to -printf
option to find
to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort
. sort -r
does reverse sorting to put the newest (i.e. "biggest") times at the beginning.
This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n
but with to null-terminate the filenames. Then add
--zero-terminated
to the sort options, and put | tr '' 'n'
at the end to convert the null bytes back into newlines.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Finding the newest 10 files under the current directory:
find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10
Optionally add | cut -f2
to strip the time information.
This uses to -printf
option to find
to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort
. sort -r
does reverse sorting to put the newest (i.e. "biggest") times at the beginning.
This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n
but with to null-terminate the filenames. Then add
--zero-terminated
to the sort options, and put | tr '' 'n'
at the end to convert the null bytes back into newlines.
Finding the newest 10 files under the current directory:
find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TSt%h/%fn" | sort -r | head -n 10
Optionally add | cut -f2
to strip the time information.
This uses to -printf
option to find
to print the modification time of the file in front of the filename separated by a tab, where the time is formatted in a way that can simply be sorted by sort
. sort -r
does reverse sorting to put the newest (i.e. "biggest") times at the beginning.
This falls down a bit with filenames that contain newlines. That can be worked around by ending the printf string not with n
but with to null-terminate the filenames. Then add
--zero-terminated
to the sort options, and put | tr '' 'n'
at the end to convert the null bytes back into newlines.
answered Jun 27 at 14:30
wurtel
8,6101822
8,6101822
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453557%2fhow-can-i-sort-find-output-by-printing-the-most-10-latest-update-files%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
ls -lrt will list in date order use man ls to look at ls options.
â Essex Boy
Jun 27 at 12:55
yes but I want to search recursive
â shalom
Jun 27 at 13:08
find with -mtime
â dmourati
Jul 5 at 3:16