System/Linux

쉘 스크립트

Tribal 2015. 11. 30. 18:44

첫 번째 예제


1. 쉘 스크립트 실행

while :;do echo "echo Input file" >> /tmp/text.sh chmod 755 /tmp/test.sh sleep 1 ;done 


2. 쉘 스크립트 작성

tribal@tribal-virtual-machine:~/debug/shell$ vim exam.sh

#!/bin/bash


while true

do

    echo "echo Input file" >> /tmp/text.sh

    chmod 755 /tmp/test.sh

    sleep 1

done



두 번째 예제


출처 : http://blog.naver.com/PostView.nhn?blogId=bestheroz&logNo=66975657&categoryNo=4&viewDate=&currentPage=1&listtype=0

1. 쉘 스크립트 실행

while :;do echo -n "담배가 좋습니까?(Yes/No) : "; read a; if [ x$a = "xYes" ] ;then break ;else continue ;fi ;done; echo "GOOD!";


2. 쉘 스크립트 작성

tribal@tribal-virtual-machine:~/debug/shell$ vim exam.sh

while 

do

echo -n "담배가 좋습니까?(Yes/No) : "

read a

if [ x$a = "xYes" ] then

break

else

continue

fi

done

echo "GOOD!"