当前目录下有一些文件和目录,其中每个目录里都有若干.txt文件,现在要求在当前目录创建一个新目录all,且将那些目录所有.txt文件。
都拷贝到目录all。在Ubuntu 12.04的shell脚本实现如下:
	
	#!/bin/sh
	# 提示信息
	echo "start:"
	# 定义变量
	dst=all
	pst=.txt
	# 复制文件到目标文件夹
	if [ -d ${dst} ]
	then
	echo "${dst} existed"
	else
	echo "mkdir ${dst}"
	mkdir ./${dst}
	cp ./*/*$pst ./$dst
	fi
	
	Shell脚本:使用rsync备份文件/目录:http://www.linuxdiyf.com/linux/12696.html

