shell寫正則表達(dá)式=~后面必須不加雙引號(hào)
image.png
!/bin/bash
function getdir(){
for element in ls $1
do
dir_or_file=element
if [ -d dir_or_file
else
if [[ " ]]
then
echo dir_or_file" =~ .sh
dir_or_file
fi
fi
done
}
root_dir="/home/work/mingyouchen/libowei"
getdir $root_dir