linux shell

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

 

posted @ 2016-06-16 16:23  agang_19  阅读(114)  评论(0编辑  收藏  举报