ShellScript

[shellscript] 기본 문법

tenn 2014. 3. 1. 17:10


*** if


x=10

if [ $x = 10 ]; then

        echo 10

else

        echo not 10

fi

※띄어쓰기 주의




*** For

#!/bin/bash


for i in 1 5 10; do
    echo $i
done



for((i=10;i>0;i--));do

        echo $i

done




*** 문자 포함


string='My string';


if [[ $string == *My* ]]

then

  echo "It's there!";

fi


http://stackoverflow.com/questions/229551/string-contains-in-bash


*** 참고할만한

http://webtn.tistory.com/33