Shell入门学习

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 &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值