Sometimes, Maybe you have some specific request as a linux admin, it is to find the smallest files or directory in a directory or in the current directory, or you need to know how to find the files or list all files or directories in a directory and sort by file size. How to find smallest files or directories using Linux find command in linux system. how to list all the smallest files or directories on your linux system. This guide will show you on how to find smallest files /directories by size under linux operating system. Find The Smallest Files In A DirectoryOften, if you want to list all files in a directory, you can use “l(fā)s” comand with a few options per your specific request. now the below example will show you how to use “l(fā)s” command with both “-S” and “-r” options to list the smallest files in a directory. where, “-r” options will reverse the sorting order of the listing. “-S” option will do sorting operation. Issue the following command to find the smallest files in the current directory:
If you just wnat to see the first 10 smallest file, you can use pipe line and follow to “head -n” command.
output:
Find The Smallest Directories In A Directory using “du” command with “-S” options, which will put the size in kilobytes of each directory in the first column of output , you can give the target directory you want to search and pipe the output to sort command with ‘-n’ option, type:
Related Articles:
|
|