Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5287212
  • 博文数量: 1144
  • 博客积分: 11974
  • 博客等级: 上将
  • 技术积分: 12312
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-13 20:06
文章存档

2017年(2)

2016年(14)

2015年(10)

2014年(28)

2013年(23)

2012年(29)

2011年(53)

2010年(86)

2009年(83)

2008年(43)

2007年(153)

2006年(575)

2005年(45)

分类: LINUX

2006-07-19 20:20:19

numargs=$#
filelist=
copylist=
while [ "$#" -gt 1 ]
do
        filelist="$filelist $1"
        shift
done
to="$1"
if [ "$numargs" -lt 2 -o "$numargs" -gt -2 -a !-d "$to" ]
then echo "usage wrong"
exit 1
fi
for from in $filelist
do
if [ -d "$to" ]
then tofile="$to/$(basename $from)"
else
tofile="$to"
fi
if [ -e "$tofile" ]
then
        echo "$tofile already exists overwrite?"
        read answer
        if [ $answer=yes ]
        then
        copylist="$copylist $from"
fi
else
copylist="$copylist $from"
fi
done
if [ -n "$copylist" ]
then
        cp $copylist $to
fi


运行错误检测   
$copp aa  #copp为文件名称
提示  mycp3[10]: [: argument expected
应该echo "usage wrong"然后退出阿  
另外 谁能解释一下exit 0 根exit 1 有什么区别呢 退出不同的层次么?
 
 
仔细比较50次
!-d
! -d

阅读(1128) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~