Skip to main content
added 68 characters in body
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

(-name . -o -name '.*' -prune -o with LC_ALL=C to exclude hidden files, like ls does by default without -a/-A when it lists the contents of directories itself)

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier. Add the D glob qualifier if you want hidden files to be included.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

(-name . -o -name '.*' -prune with LC_ALL=C to exclude hidden files, like ls does by default without -a/-A when it lists the contents of directories itself)

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

(-name . -o -name '.*' -prune -o with LC_ALL=C to exclude hidden files, like ls does by default without -a/-A when it lists the contents of directories itself)

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier. Add the D glob qualifier if you want hidden files to be included.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --
added 170 characters in body
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

(-name . -o -name '.*' -prune with LC_ALL=C to exclude hidden files, like ls does by default without -a/-A when it lists the contents of directories itself)

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

(-name . -o -name '.*' -prune with LC_ALL=C to exclude hidden files, like ls does by default without -a/-A when it lists the contents of directories itself)

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --
added 60 characters in body
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . !-name . -o -name '.*' -prune -o -exec ls -ltd {} +

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -mindepthname 1. -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

find . ! -name . -exec ls -ltd {} +

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

find . -mindepth 1 -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --

With the standard -t option, ls will sort files (given as arguments or found in the contents of directories passed argument) by modification time from newest to oldest.

With the -R option, ls enters a recursive mode, but it still lists the contents of each directory separately, so while each directory listing will be listed by modification time, you won't get a notion of the relative time of files between different directories. The files will also not be listed with their full path.

To list files recursively with their full paths, ordered by time, you'd need to pass all of them by path to ls. You could do it with:

LC_ALL=C find . -name . -o -name '.*' -prune -o -exec ls -ltd {} +

But that will break as soon as there are so many files that find needs to call ls several times to work around the execve() limit on the size or argument+environment that can be passed to a command, where you'll end up with several independent sorted lists.

To address that, you'd need to sort the list outside of ls and pass the list to those several invocations of ls -ld. With the zsh shell and a xargs that supports the -0 and -r option, that can be done with:

print -rNC1 -- **/*(Nom) | xargs -r0 ls -ltd --

If your ls supports the non-standard -U option to skip sorting, you can use that in place of -t as zsh has already sorted the list with its om (order by modification time) glob qualifier.

With the GNU implementations of find, ls, cut and sort, you can also do:

LC_ALL=C find . -name . -o -name '.*' -prune -o -printf '%T@\t%P\0' |
  sort -rzn |
  cut -zf2- |
  xargs -r0 ls -lUd --
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k
Loading