Difference between find . and find * in unix

北战南征 提交于 2020-07-07 23:00:29

问题


What is the difference between find . vs find * .

When i am trying to search for a file in current directory i.e. which was modified not more than 20 days ,i fired below query

find . -maxdepth 0 -mtime -20

The above command gives no output but

find * -maxdepth 0 -mtime -20

gives me the output that is required.Why is this happening i am searching in current directory only and . also means current directory


回答1:


. means "start with the current directory". A depth of 0 can only be ..

* means "start with the visible contents of the directory". A depth of 0 will be each of the visible items in the directory.




回答2:


In addition to what @ignacio is correctly saying, you should also take into account that:

  • find . looks for hidden files too, e.g. into the .git if there's one
  • find * looks for the visible contents only within the directory

Have a look at this answer update too, here: https://stackoverflow.com/a/22057427/6466510



来源:https://stackoverflow.com/questions/46578534/difference-between-find-and-find-in-unix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!