首页 > 应用开发 > IT综合 > shell study!!
shell study!!
#!/bin/bash
#test1.sh
current_pid=$$
ps -aux|grep "/sbin"|grep -v "grep"|awk '{print $2}'>/tmp/${current_pid}.txt
for pid in `cat /tmp/${current_pid}.txt`
do
{
echo "kill -9 $pid"
}
done
#rm -f /tmp/${current_pid}.txt
#!/bin/bash
#test2.sh
usage()
{
echo "test2.sh yuan_dir budi_dir "
}
if [ $# -ne 2 ]
then
{
usage
exit 0
}
fi
srcdir=$1
desdir=$2
if [ ! -d $srcdir ]
then
{
usage
echo "then yuan_dir ${srcdir} do not find!"
exit
}
fi
if [ ! -d $desdir ]
then
{
usage
echo "the budi_dir ${desdi}r do not find!"
exit
}
fi
processid=$$;
find $srcdir/* -type d|/usr/bin/tee /tmp/srcdir_tmp_${processid}.txt
sed "s/${srcdir}/${desdir}/g"
/tmp/srcdir_tmp_${processid}.txt>/tmp/des_tmp_${processid}.txt
#cat /tmp/srcdir_tmp_${processid}.txt > /tmp/des_tmp_${processid}.txt
rm -rf ${desdir}/*
for subdir in `cat /tmp/des_tmp_${processid}.txt`
do
{
mkdir ${subdir}
}
done
#!/bin/bash
#menu.sh
. fun.sh
echo $id
loopvar=1
menu_test
echo -n " please choose[1-4]: "
read main_choice
if [ "$main_choice" = "" ]
# you must have the kong ke!!!!!!!!!!!!!!!!!!!!!!!!!1
then
{
echo $main_choice
main_choice=5
echo " you will get out the test!!"
}
fi
while [ $loopvar -gt 0 ]
do
{
case $main_choice in
1)
# loopv=1
#while [ $loopv -gt 0 ]
#do
#{
#clear
echo -n " please input the first value v1 : "
read v1
echo -n " please input the second value v2 : "
read v2
let v3=$v1+$v2
echo " you can get the + value : " $v3
#loopv=0
#}
#done
echo " "
echo " "
menu_test
echo -n " please choose[1-4]: "
read main_choice
# menu_test
;;
2)
#clear
echo -n " please input the first value v1 : "
read v1
echo -n " please input the second value v2 : "
read v2
let v3=$v1-$v2
echo " you can get the - value : " $v3
echo " "
echo " "
menu_test
echo -n " please choose[1-4]: "
read main_choice
#menu_test
;;
3)
#clear
echo -n " please input the first value v1 : "
read v1
echo -n " please input the second value v2 : "
read v2
let v3=$v1*$v2
echo " you can get the * value : " $v3
echo " "
echo " "
menu_test
echo -n " please choose[1-4]: "
read main_choice
#menu_test
;;
4)
#clear
echo -n " please input the first value v1 : "
read v1
echo -n " please input the second value v2 : "
read v2
let v3=$v1/$v2
echo " you can get the / value : " $v3
echo " "
echo " "
menu_test
echo -n " please choose[1-4]: "
read main_choice
# menu_test
;;
5)
#clear
break 1
;;
esac
}
done
#!/bin/bash
#fun.sh
id=testi
menu_test()
{
curdate=`date "+%Y-%m-%d %T"`
cat <
* *
* * * * * *
* *
* *
* * *
* * * *
DATE : $curdate
======================================================
this is my first test
++++++++++++++++++++++++++++++++++++++++++++++++++
** 1 : input two data and you can get the + value
** 2 : input two date and you can get the - value
** 3 : input two date and you can get the * value
** 4 : input two date and you can get the / value
** 5 : run out the test
---made by imlihj
======================================================
mayday
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9879835/viewspace-1005547/ ,如需转载,请注明出处,否则将追究法律责任。