Check whether a certain file type/extension exists in directory

前端 未结 15 1740
时光取名叫无心
时光取名叫无心 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条回答
  •  梦如初夏
    2021-01-30 06:38

    #!/bin/bash
    
    count=`ls -1 *.flac 2>/dev/null | wc -l`
    if [ $count != 0 ]
    then 
    echo true
    fi 
    

提交回复
热议问题