求代码 注释
#!/bin/sh
#unload - program to backup and remove files
#syntax: unload directory /**/
#check arguments /**/
if [ $# -ne 1 ] /**/
then /**/
echo "usage: $0 directory" /**/
exit 1
fi
#check for valid directory name
if [ ! -d "$1" ]
then /**/
echo "$1 is not a directory" /**/
exit 2 /**/
fi /**/
cd $1 /**/
ls -a | cpio -o > /dev/rmt/0h /**/
if [ $? -eq 0 ] /**/
then /**/
rm -rf * /**/
else /**/
echo "A problem has occured in creating backup" /**/
echo "The directory will not be ereased" /**/
echo "Please check the backup device" /**/
exit 3 /**/
fi /**/
# end of unload /**/
#unload - program to backup and remove files
#syntax: unload directory /**/
#check arguments /**/
if [ $# -ne 1 ] /**/
then /**/
echo "usage: $0 directory" /**/
exit 1
fi
#check for valid directory name
if [ ! -d "$1" ]
then /**/
echo "$1 is not a directory" /**/
exit 2 /**/
fi /**/
cd $1 /**/
ls -a | cpio -o > /dev/rmt/0h /**/
if [ $? -eq 0 ] /**/
then /**/
rm -rf * /**/
else /**/
echo "A problem has occured in creating backup" /**/
echo "The directory will not be ereased" /**/
echo "Please check the backup device" /**/
exit 3 /**/
fi /**/
# end of unload /**/
作者: cassiel_fang 发布时间: 2011-06-08
这个都是最基本的语法呀,楼主自己来吧,上班时间到了
作者: louyong0571 发布时间: 2011-06-09
if [ $# -ne 1 ] /**/ 程序如果带的参数不是有且仅有一个,那么就打印usage: $0 directory 并退出 $0代表程序名
then /**/
echo "usage: $0 directory" /**/
exit 1
fi
#check for valid directory name
if [ ! -d "$1" ] 如果参数1不是一个目录就打印,并退出
then /**/
echo "$1 is not a directory" /**/
exit 2 /**/
fi /**/
cd $1 /**/ 进入$1目录
ls -a | cpio -o > /dev/rmt/0h /**/ 备份$1目录下文件
if [ $? -eq 0 ] /**/ 如果返回值为0,就是前面命令执行成功,删除目录下所有文件否则echo xx打印并退出
then /**/
rm -rf * /**/
else /**/
echo "A problem has occured in creating backup" /**/
echo "The directory will not be ereased" /**/
echo "Please check the backup device" /**/
exit 3 /**/
fi /**/
then /**/
echo "usage: $0 directory" /**/
exit 1
fi
#check for valid directory name
if [ ! -d "$1" ] 如果参数1不是一个目录就打印,并退出
then /**/
echo "$1 is not a directory" /**/
exit 2 /**/
fi /**/
cd $1 /**/ 进入$1目录
ls -a | cpio -o > /dev/rmt/0h /**/ 备份$1目录下文件
if [ $? -eq 0 ] /**/ 如果返回值为0,就是前面命令执行成功,删除目录下所有文件否则echo xx打印并退出
then /**/
rm -rf * /**/
else /**/
echo "A problem has occured in creating backup" /**/
echo "The directory will not be ereased" /**/
echo "Please check the backup device" /**/
exit 3 /**/
fi /**/
作者: zmlovelx 发布时间: 2011-06-09