How to recursively list all files with timestamps and full path?
I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:
10:30 Dec 10 2010 /tmp/mydir/myfile
I've tried with:
find . -type f -exec ls -la {} ;
but that doesn't give me the full path.
linux ls
add a comment |
I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:
10:30 Dec 10 2010 /tmp/mydir/myfile
I've tried with:
find . -type f -exec ls -la {} ;
but that doesn't give me the full path.
linux ls
add a comment |
I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:
10:30 Dec 10 2010 /tmp/mydir/myfile
I've tried with:
find . -type f -exec ls -la {} ;
but that doesn't give me the full path.
linux ls
I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this:
10:30 Dec 10 2010 /tmp/mydir/myfile
I've tried with:
find . -type f -exec ls -la {} ;
but that doesn't give me the full path.
linux ls
linux ls
edited Jan 4 '14 at 20:16
slhck
159k47441464
159k47441464
asked Jan 3 '11 at 11:22
user48777
1981210
1981210
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
And another way to do it if your find doesn't support printf
find . -type f | xargs ls -al | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'
Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:
2010-09-29 22:08 /home/nifle/ac.txt
2010-10-04 16:02 /home/nifle/array.sh
2010-10-05 23:32 /home/nifle/b.txt
2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
2010-09-29 22:16 /home/nifle/foo.gz
2010-09-29 22:16 /home/nifle/foo1.gz
1
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
add a comment |
Solution 1 (ls)
Run ls
on each file and filter the result:
find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-
Output:
Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
Jan 2 1972 /tmp/superuser.com/questions/228529/old_file
Solution 2 (-printf)
Use -printf
:
find "$PWD" -type f -printf "%t %pn"
Output:
Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file
Solution 3 (stat)
Run GNU stat
on each file:
find "$PWD" -type f -exec stat --format '%y %n' {} ;
Output:
2016-03-30 04:32:10.034718786 +0300 /etc/passwd
2015-12-21 19:30:07.854470768 +0200 /etc/group
Tip: if you have GNU find, ;
can be replaced with +
.
You can replace$PWD
with.
.
– Dennis Williamson
Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses.
instead of$PWD
and it doesn't give him the full path.
– Cristian Ciupitu
Jan 3 '11 at 21:09
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
add a comment |
This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:
find $ABSOLUTE_PATH_TO_DIR -ls
add a comment |
tree
is a nice alternative:
tree -fD --timefmt %c
Format the time using strftime syntax.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f228529%2fhow-to-recursively-list-all-files-with-timestamps-and-full-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
And another way to do it if your find doesn't support printf
find . -type f | xargs ls -al | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'
Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:
2010-09-29 22:08 /home/nifle/ac.txt
2010-10-04 16:02 /home/nifle/array.sh
2010-10-05 23:32 /home/nifle/b.txt
2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
2010-09-29 22:16 /home/nifle/foo.gz
2010-09-29 22:16 /home/nifle/foo1.gz
1
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
add a comment |
And another way to do it if your find doesn't support printf
find . -type f | xargs ls -al | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'
Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:
2010-09-29 22:08 /home/nifle/ac.txt
2010-10-04 16:02 /home/nifle/array.sh
2010-10-05 23:32 /home/nifle/b.txt
2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
2010-09-29 22:16 /home/nifle/foo.gz
2010-09-29 22:16 /home/nifle/foo1.gz
1
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
add a comment |
And another way to do it if your find doesn't support printf
find . -type f | xargs ls -al | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'
Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:
2010-09-29 22:08 /home/nifle/ac.txt
2010-10-04 16:02 /home/nifle/array.sh
2010-10-05 23:32 /home/nifle/b.txt
2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
2010-09-29 22:16 /home/nifle/foo.gz
2010-09-29 22:16 /home/nifle/foo1.gz
And another way to do it if your find doesn't support printf
find . -type f | xargs ls -al | awk -v pwd="$PWD" '{ print $(NF-2), $(NF-1) , pwd substr($(NF), 2)}'
Note: This only works as long as there aren't any spaces in the filenames. Output looks like this:
2010-09-29 22:08 /home/nifle/ac.txt
2010-10-04 16:02 /home/nifle/array.sh
2010-10-05 23:32 /home/nifle/b.txt
2010-12-15 16:49 /home/nifle/barcopy/subbar/ghut
2010-12-15 16:48 /home/nifle/bardir/subbar/ghut
2010-09-29 22:16 /home/nifle/foo.gz
2010-09-29 22:16 /home/nifle/foo1.gz
edited Jan 4 '14 at 20:16
slhck
159k47441464
159k47441464
answered Jan 3 '11 at 11:59
Nifle
27.9k2393128
27.9k2393128
1
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
add a comment |
1
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
1
1
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
As long as there aren't any spaces in the filenames.
– Dennis Williamson
Jan 3 '11 at 12:07
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
@Dennis - Ahh, yes you definitely have a point there.
– Nifle
Jan 3 '11 at 12:10
add a comment |
Solution 1 (ls)
Run ls
on each file and filter the result:
find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-
Output:
Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
Jan 2 1972 /tmp/superuser.com/questions/228529/old_file
Solution 2 (-printf)
Use -printf
:
find "$PWD" -type f -printf "%t %pn"
Output:
Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file
Solution 3 (stat)
Run GNU stat
on each file:
find "$PWD" -type f -exec stat --format '%y %n' {} ;
Output:
2016-03-30 04:32:10.034718786 +0300 /etc/passwd
2015-12-21 19:30:07.854470768 +0200 /etc/group
Tip: if you have GNU find, ;
can be replaced with +
.
You can replace$PWD
with.
.
– Dennis Williamson
Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses.
instead of$PWD
and it doesn't give him the full path.
– Cristian Ciupitu
Jan 3 '11 at 21:09
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
add a comment |
Solution 1 (ls)
Run ls
on each file and filter the result:
find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-
Output:
Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
Jan 2 1972 /tmp/superuser.com/questions/228529/old_file
Solution 2 (-printf)
Use -printf
:
find "$PWD" -type f -printf "%t %pn"
Output:
Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file
Solution 3 (stat)
Run GNU stat
on each file:
find "$PWD" -type f -exec stat --format '%y %n' {} ;
Output:
2016-03-30 04:32:10.034718786 +0300 /etc/passwd
2015-12-21 19:30:07.854470768 +0200 /etc/group
Tip: if you have GNU find, ;
can be replaced with +
.
You can replace$PWD
with.
.
– Dennis Williamson
Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses.
instead of$PWD
and it doesn't give him the full path.
– Cristian Ciupitu
Jan 3 '11 at 21:09
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
add a comment |
Solution 1 (ls)
Run ls
on each file and filter the result:
find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-
Output:
Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
Jan 2 1972 /tmp/superuser.com/questions/228529/old_file
Solution 2 (-printf)
Use -printf
:
find "$PWD" -type f -printf "%t %pn"
Output:
Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file
Solution 3 (stat)
Run GNU stat
on each file:
find "$PWD" -type f -exec stat --format '%y %n' {} ;
Output:
2016-03-30 04:32:10.034718786 +0300 /etc/passwd
2015-12-21 19:30:07.854470768 +0200 /etc/group
Tip: if you have GNU find, ;
can be replaced with +
.
Solution 1 (ls)
Run ls
on each file and filter the result:
find "$PWD" -type f -exec ls -la {} ; | cut -d ' ' -f 6-
Output:
Jun 14 00:02 /tmp/superuser.com/questions/370070/bar
Jun 14 20:24 /tmp/superuser.com/questions/228529/file with multiple spaces
Jan 2 1972 /tmp/superuser.com/questions/228529/old_file
Solution 2 (-printf)
Use -printf
:
find "$PWD" -type f -printf "%t %pn"
Output:
Thu Jun 14 00:02:47.0173429319 2012 /tmp/superuser.com/questions/370070/bar
Thu Jun 14 20:24:16.0947808489 2012 /tmp/superuser.com/questions/228529/file with multiple spaces
Sun Jan 2 03:04:05.0000000000 1972 /tmp/superuser.com/questions/228529/old_file
Solution 3 (stat)
Run GNU stat
on each file:
find "$PWD" -type f -exec stat --format '%y %n' {} ;
Output:
2016-03-30 04:32:10.034718786 +0300 /etc/passwd
2015-12-21 19:30:07.854470768 +0200 /etc/group
Tip: if you have GNU find, ;
can be replaced with +
.
edited Apr 7 '16 at 14:29
answered Jan 3 '11 at 11:37
Cristian Ciupitu
4,1192540
4,1192540
You can replace$PWD
with.
.
– Dennis Williamson
Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses.
instead of$PWD
and it doesn't give him the full path.
– Cristian Ciupitu
Jan 3 '11 at 21:09
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
add a comment |
You can replace$PWD
with.
.
– Dennis Williamson
Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses.
instead of$PWD
and it doesn't give him the full path.
– Cristian Ciupitu
Jan 3 '11 at 21:09
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
You can replace
$PWD
with .
.– Dennis Williamson
Jan 3 '11 at 12:08
You can replace
$PWD
with .
.– Dennis Williamson
Jan 3 '11 at 12:08
@Dennis Williamson: the command from the question already uses
.
instead of $PWD
and it doesn't give him the full path.– Cristian Ciupitu
Jan 3 '11 at 21:09
@Dennis Williamson: the command from the question already uses
.
instead of $PWD
and it doesn't give him the full path.– Cristian Ciupitu
Jan 3 '11 at 21:09
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
Ah, sorry, you are correct.
– Dennis Williamson
Jan 3 '11 at 21:23
add a comment |
This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:
find $ABSOLUTE_PATH_TO_DIR -ls
add a comment |
This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:
find $ABSOLUTE_PATH_TO_DIR -ls
add a comment |
This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:
find $ABSOLUTE_PATH_TO_DIR -ls
This question on StackOverflow plays around with one part of your question. In order to get what you want, you could try the following:
find $ABSOLUTE_PATH_TO_DIR -ls
edited May 23 '17 at 12:41
Community♦
1
1
answered Jan 3 '11 at 11:46
ayaz
6,93211525
6,93211525
add a comment |
add a comment |
tree
is a nice alternative:
tree -fD --timefmt %c
Format the time using strftime syntax.
add a comment |
tree
is a nice alternative:
tree -fD --timefmt %c
Format the time using strftime syntax.
add a comment |
tree
is a nice alternative:
tree -fD --timefmt %c
Format the time using strftime syntax.
tree
is a nice alternative:
tree -fD --timefmt %c
Format the time using strftime syntax.
answered Dec 17 at 23:55
ManuelSchneid3r
383516
383516
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f228529%2fhow-to-recursively-list-all-files-with-timestamps-and-full-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown