Server Fault Asked by Gnanam on January 5, 2021
I’m looking for a single command to list all files recursively from a given directory along with its modified time. It would also be nice if it can produce output in a tree-like format as produced by tree command.
NOTE: I’m running Red Hat Enterprise Linux Server release 5.
EDIT: The option -D
of tree command prints only the date part of the last modification time for past years, though it display date with time for current year. Here, in this case, I’m expecting to print date with time for past years as well.
I'm looking for a single command to list all files recursively from a given directory along with its modified time.
$ find /path/to/folder -type f -print0 | xargs -0 ls -l --time-style="+%F %T"
It would also be nice if it can produce output in a tree-like format as produced by tree command. In my case, precision upto minutes is enough.
On my CentOS, Gentoo, ... -D
option is already showed in minutes:
$ tree -D
.
├── [Jul 26 14:41] LICENSE
├── [Jul 26 14:41] manifests
│ ├── [Oct 10 16:30] defines
│ │ └── [Jul 26 14:41] redis source.pp
│ └── [Jul 26 14:41] init.pp
├── [Jul 26 14:41] README
└── [Jul 26 14:41] templates
├── [Jul 26 14:41] redis.conf.erb
└── [Jul 26 14:41] redis-server.erb
3 directories, 6 files
Correct answer by quanta on January 5, 2021
perhaps this could be a starting point for your solution:
tree -nf | awk '{printf $0} {system("stat -c " [ %y ]" " $NF )}'| sed -e 's#([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*#1 ]#g' 2>/dev/null
Answered by ThorstenS on January 5, 2021
This command lists recursively all files in a given directory with their full modification time:
ls -Rl --time-style=long-iso /path/to/directory
There's no tree
-like output in ls
but this is pretty close.
Answered by Vladimir Blaskov on January 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP