for file in `ls /root` //file 是变量 for 读取 root 文件夹里的文件名 赋值给file
do //执行语句
echo $file // 输出变量值
done //执行完成
vim 建立test.sh脚本 写入以上代码
执行脚本
chmod +x ./test.sh
或
/bin/bash ./test.sh

for file in `ls /root` //file 是变量 for 读取 root 文件夹里的文件名 赋值给file
do //执行语句
echo $file // 输出变量值
done //执行完成
vim 建立test.sh脚本 写入以上代码
执行脚本
chmod +x ./test.sh
或
/bin/bash ./test.sh