Check whether a certain file type/extension exists in directory

前端 未结 15 1622
时光取名叫无心
时光取名叫无心 2021-01-30 06:12

How would you go about telling whether files of a specific extension are present in a directory, with bash?

Something like

if [ -e *.flac ]; then 
echo t         


        
15条回答
  •  猫巷女王i
    2021-01-30 06:41

    #/bin/bash
    
    myarray=(`find ./ -maxdepth 1 -name "*.py"`)
    if [ ${#myarray[@]} -gt 0 ]; then 
        echo true 
    else 
        echo false
    fi
    

提交回复
热议问题