小菜鸡初接触shell写的第一个脚本,没有什么技术含量,留个纪念,如果给各位提供了丁点思路深感荣幸。
源码:
#! /usr/bin/bash
clear
echo
echo "###################################################################"
echo "# this is a bash-shell system write by lee #"
echo "# this procedure is a system 简单系统 #"
echo "# version 1.1.1.20200421 #"
echo "###################################################################"
#this function is lianxiren
return_lianxiren(){
echo '**lianixrenxinxi******'
cat lianxiren.txt
read -p "Enter name like: "
head lianxiren.txt |grep -n $REPLY
echo '********1.return_shouye******'
echo '******2.return_lianxiren*****'
echo '*************0.exit**********'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then return_shouye
elif [ $REPLY -eq 2 ]
then return_lianxiren
elif [ $REPLY -eq 0 ]
then echo 'good bye man.'
else
echo 'your chose is failed!!!'
return_lianxiren
fi
}
#this function is shouye
return_shouye(){
echo '*********shouye**********'
echo '****1.pactera_jianjie****'
echo '****2.lianxiren_chaxun***'
echo '****3.lianxiren_xiugai***'
echo '*******0.exit************'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then
cat pactera_jianjie.txt
echo '********1.return******'
echo '*********0.exit*******'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then return_shouye
elif [ $REPLY -eq 0 ]
then echo 'good bye man.'
else
echo 'your chose is failed!!!'
return_jianjie
fi
elif [ $REPLY -eq 2 ]
then
echo '**lianixrenxinxi******'
cat lianxiren.txt
read -p "Enter name like: "
head lianxiren.txt |grep -n $REPLY
echo '********1.return_shouye******'
echo '******2.return_lianxiren*****'
echo '*************0.exit**********'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then return_shouye
elif [ $REPLY -eq 2 ]
then return_lianxiren
elif [ $REPLY -eq 0 ]
then echo 'good bye man.'
else
echo 'your chose is failed!!!'
return_lianxiren
fi
elif [ $REPLY -eq 3 ]
then
vi lianxiren.txt
return_shouye
read -p "Enter your chose: "
elif [ $REPLY -eq 0 ]
then
exit
else
echo 'your chose is failed!!!'
return_shouye
fi }
return_jianjie (){
cat pactera_jianjie.txt
echo '********1.return******'
echo '*********0.exit*******'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then return_shouye
elif [ $REPLY -eq 0 ]
then echo 'good bye man.'
else
echo 'your chose is failed!!!'
return_jianjie
fi
}
##shuchushouye
echo '*********shouye**********'
echo '****1.pactera_jianjie****'
echo '****2.lianxiren_chaxun***'
echo '****3.lianxiren_xiugai***'
echo '*******0.exit************'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then
cat pactera_jianjie.txt
echo '********1.return******'
echo '*********0.exit*******'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then return_shouye
elif [ $REPLY -eq 0 ]
then echo 'good bye man.'
else
echo 'your chose is failed!!!'
return_jianjie
fi
elif [ $REPLY -eq 2 ]
then
echo '**lianixrenxinxi******'
cat lianxiren.txt
read -p "Enter name like: "
head lianxiren.txt |grep -n $REPLY
echo '********1.return_shouye******'
echo '******2.return_lianxiren*****'
echo '*************0.exit**********'
read -p "Enter your chose: "
if [ $REPLY -eq 1 ]
then return_shouye
elif [ $REPLY -eq 2 ]
then return_lianxiren
elif [ $REPLY -eq 0 ]
then echo 'good bye man.'
else
echo 'your chose is failed!!!'
return_lianxiren
fi
elif [ $REPLY -eq 3 ]
then
vi lianxiren.txt
return_shouye
read -p "Enter your chose: "
elif [ $REPLY -eq 0 ]
then
exit
else
echo 'your chose is failed!!!'
return_shouye
fi