Frequently Asked Questions

« Previous
How do I change from an Adobe Device license to a Adobe Named user license?
Next »
What about the GDPR?

windows ubuntu macos xibo network zenworks android storage

60. How do I find specific files like the last updated, the one with the longest file name, or the largest one?

See also: How do I compare the content of two directories?
These tools work on Linux (Ubuntu/CentOS/etc) and probably on macOS too.

Find the most recently updated file

Here is a small script that displays the most recently updated files in a directory. In the example this FAQ entry was the most recently updated!

$ find . -type f -print0 | xargs -0 -P 1 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -3 2018-04-27 08:55:47.517999369 +0200 ./last.updated.file.txt 2018-04-27 08:54:07.277999790 +0200 ./last.updated.file.txt~ 2018-04-27 08:51:50.658000281 +0200 ./compare.directories.txt $ _

Find the number of files and the file with the longest file name

This little script display the number of files in the current directory, the character length of the longest file name and the name of that file. There were in total 219 files and the longest filename has 49 characters in the path was ./

$ find . -type f | awk 'BEGIN{N=0} {N=N+1; if ( length > L ) { L=length ;s=$0 } }END{ print N" "L" "s }' 219 49 ./ $ _

Find the files with the longest file names

This little snippet just find print the files with the longest names:

$ find . -type f | while read ; do echo ${#REPLY} $REPLY ; done | sort -nr | head -3 45 ./ 33 ./ 30 ./win.default.printer.settings $ _

Find the largest files

This will list the largest files. It will print a list of all files, in parallell do a stat on them, sort the list and then print the largest ones.

$ find . -print0 -type f | xargs -0 stat -c "%s %n" | sort -rn | head -3 23637 ./network.8021x 20285 ./platform 18051 ./ $ _


This entry last.updated.file was last modified 2019-01-17


This documentation is covered by GNU Free Documentation License. 13 ms