使用通配符处理目录.sh Shell 脚本

Shell 片段 · codes/shell/逻辑控制/使用通配符处理目录.sh · 14 行

源码

#!/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

查看上游源码 ↗

内容与示例整理自 dunwu/linux-tutorial,遵循 CC BY-SA 4.0;本站保留原作者署名与许可,命令仅供学习,执行前请核对目标环境。