#!/bin/sh sed -i 's/alias cp/#&/' ~/.bashrc >/dev/null echo "Please input the filename:" read name array=($name*) name2="$name/*" for ((i=1; i<${#array}; i++)) do cp -r $name2 ${array[$i]} done sed -i "/#alias cp/i\alias cp='cp -i'" ~/.bashrc >/dev/null sed -i '/#alias cp/d' ~/.bashrc >/dev/null
sed -i 's/alias cp/#&/' ~/.bashrc >/dev/null把~/.bashrc文件中的alias cp一行给注释掉
array=($name*)使用通配符把所有文件夹放入数组
name2="$name/*"
${#array}获取数组长度
cp -r $name2 ${array[$i]}复制文件
<pre name="code" class="cpp" style="font-size: 14px; line-height: 21px;">sed -i "/#alias cp/i\alias cp='cp -i'" ~/.bashrc >/dev/null sed -i '/#alias cp/d' ~/.bashrc >/dev/null改回~/.bashrc文件
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/tiantuanzi/article/details/47723407