当前位置: 技术问答>linux和unix
求代码 注释
来源: 互联网 发布时间:2016-12-05
本文导语: #!/bin/sh #unload - program to backup and remove files #syntax: unload directory /**/ #check arguments /**/ if [ $# -ne 1 ] /**/ then /**/ ...
#!/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 /**/
|
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 /**/