Filenames with wildcards in variables

后端 未结 4 648
孤独总比滥情好
孤独总比滥情好 2021-01-13 02:22
#!/bin/bash
outbound=/home/user/outbound/
putfile=DATA_FILE_PUT_*.CSV
cd $outbound
filecnt=0
for file in $putfile; do let filecnt=filecnt+1; done
echo \"Filecount: \         


        
4条回答
  •  野的像风
    2021-01-13 03:17

    This is because when no matches are found, bash by default expands the wildcard DATA_FILE_PUT_*.CSV to the word DATA_FILE_PUT_*.CSV and therefore you end up with a count of 1. To disable this behavior, use shopt -s nullglob

提交回复
热议问题