用脚本拷贝目录

用脚本拷贝目录

编写shell脚本,把/root/目录下的所有目录(只需要一级)拷贝到/tmp/目录下:

#!/bin/bash

cd /root/
list=(`ls`)

for i in ${list[@]}
do
   if [ -d $i ]
   then
       cp -r $i /tmp/
   fi
done
发布了147 篇原创文章 · 获赞 27 · 访问量 8450

猜你喜欢

转载自blog.csdn.net/weixin_46108954/article/details/104786359