Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list all the files in a directory and subdirectories in reverse chronological order?

Tags:

find

unix

ls

I want to do something like ls -t but also have the files in subdirectories included. But the problem is that I don't want the output formated like ls -R does, which is like this:

[test]$ ls -Rt b       testdir test  ./testdir: a 

I want it to be formatted like the find command displays files in subdirectories. I.e:

[test]$ find . . ./b ./test ./testdir ./testdir/a 

But what find doesn't seem to do is order the result chronologically by last update time.

So how can I list all the files in a directory and subdirectories, in the format that find does, but in reverse chronological order?

like image 292
dan Avatar asked Feb 05 '11 21:02

dan


People also ask

How do I list files in a directory and its subdirectories?

The ls command is used to list files or directories in Linux and other Unix-based operating systems. Just like you navigate in your File explorer or Finder with a GUI, the ls command allows you to list all files or directories in the current directory by default, and further interact with them via the command line.

How do you list files and folders with respective file or directory name in reverse order?

Listing files in reverse name order To reverse the listing of files by name, add the -r (reverse) option. This will be like turning the normal listing upside down.

Which command gives you a full list of files reverse ordered by time?

If you want to get the results in the reverse sort order, use the -r option. It's worth mentioning that the ls command does not show the total space occupied by the directory contents. To get the size of a directory , use the du command.


1 Answers

ls -lR is to display all files, directories and sub directories of the current directory ls -lR | more is used to show all the files in a flow.

like image 156
rashmi Avatar answered Sep 27 '22 18:09

rashmi