码迷,mamicode.com
首页 > 系统相关 > 详细

linux-shell编程笔记01

时间:2015-07-21 12:04:56      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

==============常用命令

env
echo $path
export
-------------
cp
mv
mkdir
rm
-------------
cd
ls
ll
-------------
more
cat
tail
vi
-------------
ifconfig
getconf LONG_BIT
df -h

 

==============shell语法

#!/bin/bash
#test1
echo "Hello shell"
echo `who`
echo "who"
-----------------------
#!/bin/bash
#t2
echo "test 2"
var1=1
var2=2
let var3=$var2+$var1
echo $var3
echo "end!"
-----------------------
#!/bin/bash
#t3
echo "test 3"
echo "input first integer please:"
read var1
echo "input second integer please:"
read var2
let var3=var2+var1
echo $var1+$var2=$var3
echo "end!"
-----------------------
#!/bin/bash
#t4
echo "test 4"
var1=$1
if [ $var1 -lt 0 ]
then
echo "illegal!"
fi
echo "end!"
-----------------------
#!/bin/bash
#t5
echo "test 5"
var1=$1
if [ $var1 -lt 0 ]
then
echo "illegal!"
else
echo "Yeah!"
fi
echo "end!"

-----------------------
#!/bin/bash
#t6
echo "test 6"
var1=$1
if [ $var1 -lt 0 ]
then
echo "illegal!"
elif [ $var1 -lt 60 ]
then
echo "fail!"
else
echo "Yeah!"
fi
echo "end!"

-----------------------
#!/bin/bash

sum=0
for ((i=1;i<101;i++))
{
    let "sum+=i"
}
echo "sum=$sum"

-----------------------
#!/bin/bash

for animal in cat dog pig duck mice
do
    echo $animal
done

-----------------------
#!/bin/bash

sum=0
echo "input your number:"
read num

while(($num>0))
do
    let "sum+=num"
    let "num--"
done

echo "sum=$sum"

 

linux-shell编程笔记01

标签:

原文地址:http://www.cnblogs.com/SeaSky0606/p/4663776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!