Chinaunix

标题: 如何显示大小不为零的文件? [打印本页]

作者: huowz    时间: 2015-12-29 11:06
标题: 如何显示大小不为零的文件?
如题,只显示文件名即可,每行一个。
ls好像没有这个选项。
作者: yjh777    时间: 2015-12-29 12:00
find 有这个功能:
man find
作者: action08    时间: 2015-12-29 12:47
对,find -size选项可以有
  1. shell@localhost:~$ find -size 0
  2. ./.config/enchant/en.dic
  3. ./.config/enchant/en.exc
  4. ./.config/chromium/Default/Web Data-journal
  5. ./.config/chromium/Default/History-journal
  6. ./.config/chromium/Default/data_reduction_proxy_leveldb/LOCK
  7. ./.config/chromium/Default/data_reduction_proxy_leveldb/000003.log
  8. ./.config/chromium/Default/Login Data-journal
  9. ./.config/chromium/Default/Favicons-journal
  10. ./.config/chromium/Default/Top Sites-journal
  11. ./.config/chromium/Default/Shortcuts-journal
  12. ./.config/chromium/Default/Network Action Predictor-journal
  13. ./.config/chromium/Default/Cookies-journal
  14. ./.config/chromium/Default/Local Storage/chrome-extension_pafkbggdmjlpgkdkcbjmhmfcdpncadgh_0.localstorage-journal
  15. ./.config/chromium/Default/Local Storage/http_pan.baidu.com_0.localstorage-journal
  16. ./.config/chromium/Default/Local Storage/http_static.atm.youku.com_0.localstorage-journal
  17. ./.config/chromium/Default/Local Storage/http_www.reabuy.com_0.localstorage-journal
  18. ./.config/chromium/Default/Local Storage/https_wx.qq.com_0.localstorage-journal
  19. ./.config/chromium/Default/Local Storage/https_wx2.qq.com_0.localstorage-journal
  20. ./.config/chromium/Default/Local Storage/https_web.yixin.im_0.localstorage-journal
  21. ./.config/chromium/Default/Local Storage/https_www.taobao.com_0.localstorage-journal
  22. ./.config/chromium/Default/Local Storage/http_bbs.chinaunix.net_0.localstorage-journal
  23. ./.config/chromium/Default/Local Storage/http_ui.ptlogin2.qq.com_0.localstorage-journal
  24. ./.config/chromium/Default/Local Storage/http_www.haosou.com_0.localstorage-journal
  25. ./.config/chromium/Default/Local Storage/http_fm.baidu.com_0.localstorage-journal
  26. ./.config/chromium/Default/Local Storage/http_music.baidu.com_0.localstorage-journal
  27. ./.config/chromium/Default/Local Storage/http_pos.baidu.com_0.localstorage-journal
  28. ./.config/chromium/Default/Local Storage/http_v.qq.com_0.localstorage-journal
  29. ./.config/chromium/Default/Local Storage/http_api.t.qq.com_0.localstorage-journal
  30. ./.config/chromium/Default/Local Storage/http_t.qq.com_0.localstorage-journal
  31. ./.config/chromium/Default/Local Extension Settings/pafkbggdmjlpgkdkcbjmhmfcdpncadgh/LOCK
  32. ./.config/chromium/Default/Extension State/LOCK
  33. ./.config/chromium/Default/Session Storage/LOCK
  34. ./.config/chromium/Default/Origin Bound Certs-journal
  35. ./.config/chromium/First Run
  36. ./.config/chromium/Safe Browsing Cookies-journal
  37. ./.local/share/mime/XMLnamespaces
  38. ./.local/share/mime/subclasses
  39. ./.local/share/mime/aliases
  40. ./.local/share/mime/generic-icons
  41. ./.local/share/mime/icons
  42. ./.gconf/apps/%gconf.xml
  43. ./.mozilla/firefox/tuz79qxc.default/.parentlock
  44. shell@localhost:~$
  45. shell@localhost:~$
  46. shell@localhost:~$ cat ./.local/share/mime/icons
  47. shell@localhost:~$
复制代码
看样子是对了
作者: action08    时间: 2015-12-29 12:49
  1.        -size n[cwbkMG]
  2.               File uses n units of space.  The following suffixes can be used:

  3.               `b'    for  512-byte blocks (this is the default if no suffix is
  4.                      used)

  5.               `c'    for bytes

  6.               `w'    for two-byte words

  7.               `k'    for Kilobytes (units of 1024 bytes)

  8.               `M'    for Megabytes (units of 1048576 bytes)

  9.               `G'    for Gigabytes (units of 1073741824 bytes)

  10.               The size does not count  indirect  blocks,  but  it  does  count
  11.               blocks in sparse files that are not actually allocated.  Bear in
  12.               mind that the `%k' and `%b' format specifiers of -printf  handle
  13.               sparse   files  differently.   The  `b'  suffix  always  denotes
  14.               512-byte blocks and never 1 Kilobyte blocks, which is  different
  15.               to the behaviour of -ls.
复制代码
对shell不是很懂,大牛来一个正确的吧
作者: huowz    时间: 2015-12-30 15:11
find倒是真的可以,不过前面多了‘./’,好在我的文件名都是定长的,加上cut,就达到要求了,谢谢大家!
作者: leijskg    时间: 2015-12-30 15:26
提示: 作者被禁止或删除 内容自动屏蔽
作者: chengchow    时间: 2015-12-30 16:21
echo `ls` | sed -r 's/\s+/\n/g'
ls -l | awk '$0=$9'





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2