Tag Archives: ls

List large files in Linux

Command to find and list all files above a defined size. Works for debian based distros and Centos.  If the output its wrong in other systems, you can play with awk params.

 bash | 
 
 copy code |
?

1
find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Find latest file in a directory methods

Sometimes there are so many files in a directory that it’s hard to find the last file in the directory. We show you here 2 ways for finding it out.

With awk we print the last argument of the last line:

 bash | 
 
 copy code |
?

1
$ ls -lrt | awk '{ f=$NF }; END{ print f }'

Reverse ordering with ls and then getting the first line:

 bash | 
 
 copy code |
?

1
$ ls -t1 | head -n1