Bash for loop with wildcards and hidden files

后端 未结 4 1660
Happy的楠姐
Happy的楠姐 2020-12-10 00:41

Just witting a simple shell script and little confused:

Here is my script:

% for f in $FILES; do echo \"Processing $f file..\"; done
<
4条回答
  •  天命终不由人
    2020-12-10 01:22

    The default globbing in bash does not include filenames starting with a . (aka hidden files).

    You can change that with

    shopt -s dotglob

    $ ls -a
    .  ..  .a  .b  .c  d  e  f
    $ ls *
    d  e  f
    $ shopt -s dotglob
    $ ls *
    .a  .b  .c  d  e  f
    $ 
    

    To disable it again, run shopt -u dotglob.

提交回复
热议问题