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

14 lines
237 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
#iterate through all the files in a directory
for file in /home/tiandi/test/*
do
2019-10-10 08:56:31 +08:00
if [ -d "$file" ]
then
echo "$file is a directory"
elif [ -f "$file" ]
then
echo "$file is a file"
fi
2019-05-10 11:17:57 +08:00
done