linux-tutorial/codes/shell/逻辑控制/使用通配符处理目录.sh

14 lines
218 B
Bash
Raw Normal View History

2019-10-29 18:22:19 +08:00
#!/usr/bin/env bash
#iterate through all the files in a directory
for file in /home/tiandi/test/*
do
if [ -d "$file" ]
then
echo "$file is a directory"
elif [ -f "$file" ]
then
echo "$file is a file"
fi
done