jQuery火箭图标返回顶部代码

功能:把/d/tmp1/里的tmp2及其子目录ttt和文件abc.html拷贝到目录/d/tmp/

实现代码

#!/bin/bash
for subm in `ls /d/tmp1`; do
echo $subm
  for file in `ls /d/tmp1/$subm`;do
  echo $file
  cp -rf /d/tmp1/$subm/$file /d/tmp/
  done
done

输出:

$ ls -l /d/tmp1/
total 0
drwxr-xr-x 1 brian 197121 0 5月 30 16:16 tmp2/

$ ls -l /d/tmp/
total 0

$ sh abc.sh
tmp2
abc.html
tta
ttt

$ ls /d/tmp
abc.html bbb.html tta/ ttt/

也可增加该文件是目录还是文件的判断。

原文地址:https://www.cnblogs.com/v5captain/p/12993475.html