Linux Shell ±Ê¼Ç¶þ(Ñ»·½á¹¹)
³ÌÐò12£ºÀàËÆjava ÀïÃæµÄswitch case
[root@localhost scripts]# cat sh12.sh
read -p "input comand:" command
case $command in
"fix")
echo "fix system"
;;
"fuck")
echo "fuck you"
;;
*)
echo "what a stupid man!ex>$0 some word"
esac
exit 0
³ÌÐò13£º¼òµ¥¼òµ¥£¬³¬¼¶¼òµ¥µÄÒ»¸öº¯Êý
[root@localhost scripts]# cat sh13.sh
function printit()
{
echo -n "Your choice is $1"
}
#$1Ϊ¿ØÖÆÌ¨ÊäÈëµÄµÚ¶þ¸ö²ÎÊý
printit 1;echo $1 | tr 'a-z' 'A-Z'
³ÌÐò14:until do done
[root@localhost scripts]# cat sh14.sh
until [ "$yn" = "yes" ] || [ "$yn" == "YES" ]
do
read -p "please input yes/to stop this program:" yn
done
³ÌÐò15£ºwhile do done
[root@localhost scripts]# cat sh15.sh
s=0
i=0
while [ "$i" != "100" ]
do
i=$(($i+1))
s=$(($s+$i))
done
echo "number of 1+2+3+...+100=$s"
³ÌÐò16£ºfor do done
[root@localhost scripts]# cat sh16.sh
s=0
for((i=1;i<=100;i=i+1))
do
s=$(($s+$i))
done
echo $s
exit 0
³ÌÐò17:for do done(2)
[root@localhost scripts]# cat sh17.sh
for animal in dog cat elephant
do
echo "there are ""$animal"
done
exit 0
³ÌÐò18£ºÀûÓà for do done²éÕÒijһ¸öĿ¼ÏÂÃæµÄÎļþȨÏÞÐÅÏ¢
[root@localhost scripts]# cat sh18.sh
read -p "input a directory:" dir
if [ "$dir" == "" ] || [ ! -d "$dir" ]; then
echo "The $dir is not exist in the system"
exit 1
fi
echo `ls $dir`
filelist=`ls $dir`
for filename in $filelist
do
perm="";
test -r "$dir/$filename" && perm="$perm readable"
test -w "$dir/$filename" && perm="$perm writable"
test -x "$dir/$filename" && perm="$perm execuatable"
echo "The file $dir/$filename's permission is $perm"
done
Ïà¹ØÎĵµ£º
Linux ÏÂʲô¶¼±È½ÏÂé·³£¬¾ÍÁ¬ÐÞ¸ÄÖ÷»úÃûÒ²²»ÀýÍâ¡£
Linux °²×°ºÃºó£¬ÆäĬÈϵÄÖ÷»úÃûÊÇ localhost¡£ÐÞ¸Ä Linux Ö÷»úÃûÐèÒª3²½¡£
ʹÓà hostname Ð޸ĵ±Ç°Ö÷»úÃû¡£
hostname new-hostname
ÐÞ¸Ä /etc/sysconfig/network ÅäÖÃÎļþ£¬ÒÔ±ãÏ´ÎÖØÆôµÄʱ£¬Ê¹ÓÃеÄÖ÷»úÃû¡£
´ò¿ª /etc/sysconfig/network Îļþ£ ......
# uname -a # ²é¿´ÄÚºË/²Ù×÷ϵͳ/CPUÐÅÏ¢
¡¡¡¡# head -n 1 /etc/issue # ²é¿´²Ù×÷ϵͳ°æ±¾
¡¡¡¡# cat /proc/cpuinfo # ²é¿´CPUÐÅÏ¢
¡¡¡¡# hostname&nb ......
Ò»¡¢svn¿Í»§¶Ë°²×°¼°»·¾³ÅäÖÃ.
¹ûËùÔÚµÄlinux»úÆ÷ÉÏûÓа²×°svn¿Í»§¶Ë£¬ÔòÊ×ÏȰ²×°svn¿Í»§¶Ë£º
1. subversion-1.4.3.tar.bz2 subversion-deps-1.4.3.tar.bz2
2. ʹÓÃ
tar xvfj subversion-1.4.3.tar.bz2
tar xvfj subversion-deps-1.4.3.tar.bz2
½âѹÕâÁ½¸öÎļþ(²»ÒªÂÒÁË˳Ðò)£¬´ËʱÔÚµ±Ç°Ä¿Â¼Ï»á³öÏÖsubvers ......
1. linux ͼÐλ¯½çÃæÂÒÂ룬һ°ãÊÇÒòΪûÓа²×°ÖÐÎÄ×ÖÌåµ¼Ö£¬¿ÉÒÔÔÚÖն˲éѯÒѾ°²×°µÄ×ÖÌå rpm -qa | grep fonts
Èç¹ûûÓÐfont-chinese£¬¿ÉÒÔÏÂÔØ»ò´Ó°²×°ÅÌÖÐÕÒµ½ fonts-chinese-3.02-12.el5.noarch.rpm °²×°¼´¿É¡£
2. Ô¶³ÌÁ¬½ÓÖÐÎÄÂÒÂ룺
vi /etc/sysconfig/i18n
½«ÄÚÈݸÄΪ
LANG="zh_CN. ......