用心、精心、决心、匠心
******************************************************* * MENU * * 1.copy 2.rename * * 3.remove 4.find * * 5.exit *
*******************************************************
即用户按下数字1,则提示用户输入源和目的文件名后执行复制;输入数字2,则提示用户输入要更名的文件或目录后执行更名操作;输入数字3,则提示用户输入要删除的文件并执行删除操作;输入数字4,则提示用户输入要查找的文件并执行查找操作;输入数字5,则退出该菜单shell程序的执行。 #! /bin/sh - clear
while [ 0 ]; do
echo \ echo \ echo \ echo \ echo \ echo \ echo
echo -n \ read choice echo
case $choice in
1)
echo -n \ read src echo
echo -n \ read des
cp -arf $src $des if $?; then
echo \ echo \
呕心沥血整理word46
else
用心、精心、决心、匠心
fi;;
echo -n \ read src echo
echo -n \ read des mv $src $des if $?; then
echo \ echo \ else fi;;
echo -n \ read src rm -rf $src if $?; then else
echo \ fi;;
echo -n \ read src
find $HOME -name $src;; 2)
3)
echo \
4)
5) exit;;
*) echo \
esac done
2. 编写shell程序,实现自动删除50个用户账号的功能。账号名为stud1至stud50 #!/bin/sh i=1
while [ $i -le 50 ]
呕心沥血整理word47
用心、精心、决心、匠心
do
userdel -r stud${i} i=$(($i+1 )) done
echo \
else
echo \
fi;;
3.用shell编写小九九乘法表程序,程序执行结果如下:#! /bin/sh – for i in 1 2 3 4 5 6 7 8 9 do for j in 1 2 3 4 5 6 7 8 9 do
if ( test $j -le $i ) then
echo -ne `expr $i \\* $j` \
else echo
break
fi
done
done
呕心沥血整理word48
相关推荐: