du: option requires an argument — ‘X’

NeilZhang
NeilZhang
管理员
140
文章
106.8千
浏览
Linux评论601字数 269阅读0分53秒阅读模式

Several days ago I encountered this little issue and I found it was very interesting. du: option requires an argument — ‘X’-图片1

I got a capacity issue and when I run 'du -sh *' I got error message similar with below:

  1. root@debian:/tmp# du -sh *
  2. du: option requires an argument -- 'X'
  3. Try 'du --help' for more information.

I have run such commands many many times so I make sure it should be workable, but I still run 'du --help' to read the help manual. Of course I could not find my answer.

While the 'ls *' worked well and the command 'du' was the right one I wanted to use.

  1. root@debian:/tmp# ls *
  2. transmission_bromolow-5.2_2.94-17.spk
  3. root@debian:/tmp# which du
  4. /usr/bin/du
  5. root@debian:/tmp# alias
  6. root@debian:/tmp# du transmission*
  7. 3892 transmission_bromolow-5.2_2.94-17.spk

When I first got this issue, I got confused and had to ignore it to deal with other urgent issue, while this time I decided to find the reason.

I found it soon!

  1. root@debian:/tmp# ls
  2. transmission_bromolow-5.2_2.94-17.spk -X
  3. root@debian:/tmp# ls -l *
  4. -rw-r--r-- 1 root root 3983360 Jun 2 21:19 transmission_bromolow-5.2_2.94-17.spk
  5. root@debian:/tmp# ls -l
  6. total 3892
  7. -rw-r--r-- 1 root root 3983360 Jun 2 21:19 transmission_bromolow-5.2_2.94-17.spk
  8. -rw-r--r-- 1 root root 0 Jun 3 18:07 -X
  9. root@debian:/tmp# du -sh *
  10. du: option requires an argument -- 'X'
  11. Try 'du --help' for more information.
  12. root@debian:/tmp# du -sh -- -X
  13. 0 -X
  14. root@debian:/tmp# rm -- -X
  15. root@debian:/tmp# du -sh *
  16. 3.9M transmission_bromolow-5.2_2.94-17.spk

The root cause was simple and I believe you could find it easily from the above command output, right? du: option requires an argument — ‘X’-图片2

 
  • 本文由 NeilZhang 发表于03/06/2018 18:26:04
  • Repost please keep this link: https://www.dbcloudsvc.com/blogs/linux/du-option-requires-an-argument-x/
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定