for f in `ls`; do
echo "File -> $f"
done
http://superuser.com/questions/31464/looping-through-ls-results-in-bash-shell-script
for f in `ls`; do
echo "File -> $f"
done
http://superuser.com/questions/31464/looping-through-ls-results-in-bash-shell-script
* 쉘스크립트이름 : $0
* 파라메터 개수 : $#
-> 파라메터에 *를 사용하면, 자동으로 해당파일 이름들로 변환된다.
-> *.txt를 파라메터로 했을 때, txt파일이 5개 있다면 $#의 값은 5가된다.
* 파라메터 : $0〜$n
if [ "$#" -eq 0 ]
// 파라메터가 없을 때
http://blog.naver.com/PostView.nhn?blogId=eleexpert&logNo=140125262113
*
*** 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
*** 참고할만한
hello.sh
#!/bin/bash
echo "Hello World"
$ chmod +x
$ ./hello.sh
Hello World
$