Linux / UNIX find the smallest directories or files in current directory

Linux / UNIX find the smallest directories or files in current directory

To find the smallest directories or files in the current directory on a Linux or Unix system, you can use the find command with the -size option. find is a utility that allows you to search for files based on various criteria, such as size, permissions, and modification time.

To find the smallest directories in the current directory, you can use the find command with the -type d option to search for directories, and the -size option to specify the minimum size:

find . -type d -size -1024c
Sourc‮e‬:www.lautturi.com

This will find all directories in the current directory (.) that are less than 1024 bytes in size. The c suffix specifies the size in bytes.

To find the smallest files in the current directory, you can use the find command with the -type f option to search for files, and the -size option to specify the minimum size:

find . -type f -size -1024c

This will find all files in the current directory that are less than 1024 bytes in size.

You can also use the -ls option to list the found files and directories with additional information, such as the file size and modification time:

find . -type f -size -1024c -ls

For more information about using the find command to search for files and directories on a Linux or Unix system, you can consult the find documentation or seek assistance from a qualified Linux or Unix administrator.

Created Time:2017-10-29 22:08:55  Author:lautturi