小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Linux:How To Find Smallest Files /Directories In A Directory ? IT Sprite

 CNTech 2015-01-19

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 Directory

Often, 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:

1
ls -lSr

If you just wnat to see the first 10 smallest file, you can use pipe line and follow to “head -n” command.

1
ls -lSr | head -n 10

output:

1
2
3
4
5
6
7
8
9
10
11
[root@itsprite var]# ls -lSr | head -n 10
total 64
lrwxrwxrwx.  1 root root   10 Dec 17  2012 mail -> spool/mail
drwxr-xr-x.  2 root root 4096 Sep 23  2011 yp
drwxrwxrwt.  2 root root 4096 Sep 24 15:38 tmp
drwxr-xr-x.  8 root root 4096 Dec 17  2012 spool
drwxr-xr-x. 10 root root 4096 Jun 27 18:04 run
drwxr-xr-x.  2 root root 4096 Sep 23  2011 preserve
drwxr-xr-x.  2 root root 4096 Sep 23  2011 opt
drwxr-xr-x.  2 root root 4096 Sep 23  2011 nis
drwxr-xr-x.  4 root root 4096 Oct 12 03:27 log

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:

1
du -S . | sort -n | head -n 10

 
Output:

1
2
3
4
5
6
7
8
9
10
11
[root@itsprite var]# du -S .  | sort -n | head -n 10
4       .
4       ./cache
4       ./cache/man/cat1
4       ./cache/man/cat2
4       ./cache/man/cat3
4       ./cache/man/cat4
4       ./cache/man/cat5
4       ./cache/man/cat6
4       ./cache/man/cat7
4       ./cache/man/cat8

 
See Also:
1.  Linux Find Command Examples
2. Linux find command
3. Linux find command manual page
Done….
 

Related Articles:

  1. Linux: Finding Out All large files (16)
  2. Linux: Finding files using linux find command (16.6)
  3. Linux commands: How To find files or directories (19)
  4. Linux Commands: Linux Find Command Examples (19.5)
  5. CentOS /Linux: Deep Understand Linux Man Command (23.7)
  6. Linux:How To Find All Files OR Directories Which Belong To A User Or Group (25)
  7. Linux:How To Find Largest Files /Directories In A Directory (37.1)
  8. Linux:How To Setup A Shared Directory (17.5)
  9. Linux: Deleting Directory Using Rmdir Or Rm Command (18)
  10. Linux: Get Directory Name From File’s Absolute Path (14.3)
  11. Linux:How to find all Hidden Files or directories (25.1)
  12. Linux:4 ways to Delete All Files In A Directory But Some Speicial Files (15.2)
  13. Linux/Unix:How to use find command to search files in linux (26)
  14. Linux / Unix: How to Find and delete All Hidden Dot Directories (14)


    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多