首页 > 系统服务 > 详细

linux shell

时间:2016-06-16 17:52:20      阅读:139      评论:0      收藏:0      [点我收藏+]

ls -l > log.txt (标准输出)

ls -l >> log.txt (标准错误输出)

while condition do

  statements

done;
for file in $(ls); do
    
    statments

done
#!/bin/sh
echo "Enter passport"
read tryThis  

while [ "$tryThis" != "secret" ]; do 
    echo "Sorry, try agian"
    read tryThis
done
exit 0;

 

#!/bin/bash
read day;
    case $day in
     yes | YES | y) echo ‘dddddddddddd‘;;
     no) echo ‘nono‘;;
    *) echo ‘&&&&&&&&&‘;;
    esac
exit 0

 

#!/bin/sh

touch 2.txt
if [ -f 2.txt ] && echo ‘2.txt exists‘ && [ -f 3.txt ] && echo ‘3.txt exit‘ 
    then
        echo ‘in if‘
    else
        echo ‘not in‘
    fi
exit 0
~                                                                                                                  
~             

 

#!/bin/sh
sample_text="global variable"
foo() {
    local sample_text="local";           //声明局部变量
    echo $sample_text
}
echo $sample_text;
foo
exit;

 

#!/bin/sh
echo > 1.txt
echo >2.txt
mkdir 3.txt

for file in *.txt
do
    if [ -d $file ]; then
        echo $file
        break
    fi
done

 

linux shell

原文:http://www.cnblogs.com/agang-php/p/5591389.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!