'ShellScript'에 해당되는 글 4건

  1. 2014.03.02 [shellscript] 디렉토리 안의 파일 보기
  2. 2014.03.01 [shellscript] parameter
  3. 2014.03.01 [shellscript] 기본 문법
  4. 2014.03.01 [shellscript] Hello World


for f in `ls`; do

  echo "File -> $f"

done

http://superuser.com/questions/31464/looping-through-ls-results-in-bash-shell-script

Posted by tenn
,


* 쉘스크립트이름 : $0

* 파라메터 개수 : $#

-> 파라메터에 *를 사용하면, 자동으로 해당파일 이름들로 변환된다.

-> *.txt를 파라메터로 했을 때, txt파일이 5개 있다면 $#의 값은 5가된다.


* 파라메터 :  $0〜$n



if [ "$#" -eq 0 ]

// 파라메터가 없을 때



http://blog.naver.com/PostView.nhn?blogId=eleexpert&logNo=140125262113










Posted by tenn
,


*** 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








Posted by tenn
,


hello.sh

#!/bin/bash


echo "Hello World"





$ chmod +x

$ ./hello.sh

Hello World

$



Posted by tenn
,