欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Shell入门学习 博客分类: Linux RubyBash 

程序员文章站 2024-02-21 20:02:04
...
Env 输出系统变量

$ echo $HOME
/home/zhangyc

设置PATH
/etc/profile
PATH=$PATH:.    原有path加上当前路径"."
export PATH
这样通过xxx.sh可以直接执行shell


#The First shell
#echo "please enter your name:"
#read fname
#echo ${fname}
s=xxx
echo $s
echo "the data is " `date`
expr 4 + 5
echo $((4+5))



#命令行读写
#!/bin/bash
echo "please enter total number"
read totalNumber
echo "please enter resolve number"
read resNumber
echo $((totalNumber - resNumber))



#条件分支
echo "please enter score:"
read score
if [ $score -lt 80 ]
then 
	echo "wrong"
elif [ $score -ge 80 -a $score -lt 90 ]
then 
	echo "good"
else 
	echo "very good"
fi



#switch
echo "service: "
echo -n "1) ls"
echo -n "2) ls -l"
echo -n "3} Exit"
echo "please choice[1-3]"

read choice
case $choice in
	1) ls;;
	2) ls -l;;
	3) exit;;
	*) echo "wrong input";;
esac



#循环
ecode=1000
while [ $ecode -le 1002 ]
do
	echo "please enter employee info ecode=$ecode"
	echo -n "enter name:" #加入-n后,不换行
	read name
	echo -n "enter email:"
	read email
	echo "name:$name email:$email" >> employee.dat
	((ecode=$ecode+1))
done


#输出执行时间
time find /etc/ -name passed
#在后台运行
find /etc/ -name passed &

相关标签: Ruby Bash