In shell scripting, what does .[!.]* mean?

前端 未结 3 405
挽巷
挽巷 2021-01-13 02:56

A command that prints a list of files and folders in the current directory along with their total sizes is du -sh *. That command alone doesn\'t, however, list

3条回答
  •  爱一瞬间的悲伤
    2021-01-13 03:22

    .[!.]* the meaning is any file or directory name start with . but not following with ., so it will include all hidden files and directories under current directory but exclude parent directory.

    Because this behaviour is decided by shell glob pattern. So you can use ls .[!.]* to see what actually get in your shell environment.

    BTW, you can turn dotglob on in your shell to simplify your du command.

    $ shopt -s dotglob
    $ du -sh *
    $ shopt -u dotglob
    

    From bash manual

    dotglob If set, bash includes filenames beginning with a `.' in the results of pathname expansion.

提交回复
热议问题