BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: ¸·°É¸® ½© ÇÁ·Î±×·¡¹Ö 1 Á¶È¸¼ö: 6056

mageoli@hotmail.com
http://¾ø½ÃÀ¯

½©ÇÁ·Î±×·¡¹Ö 1.

½© ÇÁ·Î±×·¡¹Ö¿¡ ù¶óÀο¡´Â #!/bin/shÀ» ²À ÷ºÎÇؾß
ÇÑ´Ù.

¸ÕÀú ½ºÅ©¸³Æ®¸¦ ÀÛ¼ºÇÒ¶§´Â È®ÀåÀÚ°¡ shÀÎ È­ÀÏÀ» »ý¼ºÇÑ´Ù.
²À È®ÀåÀÚ°¡ sh°¡ ¾Æ´Ï¾îµµ ±¦ÂúÀºµ¥ shÀÎ È®ÀåÀÚ¸¦ ¾²´ÂÀÌÀ¯´Â
±¸ºÐÀ» ½±°Ô Çϱâ À§Çؼ­ÀÌ´Ù
ÀÛ¼ºÇÏ°í ³­ ÆÄÀÏÀº ' chmod +x È­Àϸí ' Áï,½ÇÇàÆÄÀÏ·Î ¸¸µç´Ù
È­ÀϸíÀ» ¸í·É¾î ó·³ »ç¿ëÇÏ°Ô µÈ´Ù

½ÇÇà½Ã¿¡ ¸í·É¾î¸¦ ãÀ» ¼ö ¾ø´Ù°í Çϸ鼭 ¿¡·¯ ¸Þ½ÃÁö°¡ ³ª¿À¸é
¾Æ¸¶µµ ȯ°æº¯¼ö PATH¿¡ ÇöÀç µð·ºÅ丮°¡ ¼³Àú¿Àµð¾î ÀÖÁö ¾Ê¾Æ¼­
ÀÏ°ÍÀÌ´Ù. À̹®Á¦´Â 'PATH=$PATH:.'¸¦ bash.profile¿¡ Àû¾î ³Ö°Å³ª
¸í·ÉÇà¿¡¼­ ÀÔ·ÂÇÏ°Ô µÇ¸é ÇØ°áµÈ´Ù

ÀϹÝÀûÀ¸·Î ½ÇÇàÇÒ ÆÄÀÏ¿¡ ´ëÇÑ »ó´ë °æ·Î¸¦ ./first.h¿Í °°ÀÌ
ÁöÁ¤ÇÏ´Â ¹æ¹ýÀ» ¸¹ÀÌ »ç¿ëÇÑ´Ù.
root»ç¿ëÀÚÀÎ °æ¿ì¿¡´Â ÇöÀç µð·ºÅ丮°¡ PATH¿¡ ÀâÇôÀÖÀ¸¸é À§Çè
ÇÒ¼ö ÀÖ´Ù. Áï, root ·Î ·Î±äÇÑ °ü¸®Àڴ ǥÁØ ¸í·É¾î¿Í °°Àº
À̸§À¸·Î µÇ¾îÀÖ´Â °¡Â¥ ÇÁ·Î±×·¥À» ½ÇÇà ÇÒ¼öµµ ÀÕ´Â º¸¾È»óÀÇ
±¸¸ÛÀÌ »ý±â±â ¶§¹®ÀÌ´Ù

1. º¯¼ö
½©¿¡¼­ º¯¼ö´Â »ç¿ëÇϱâ Àü¿¡´Â ¼±¾ðÇÒ ÇÊ¿ä°¡ ¾ø°í, ´ë½Å º¯¼ö¸¦
óÀ½À¸·Î »ç¿ëÇÒ¶§ ¸¸µç´Ù. Áï, º¯¼ö¿¡ ÃʱⰪÀ» ¹®ÀÚ¿­ Çü´ë·Î
ÀúÀåµÈ´Ù.
ex)
" º¯¼ö¸í = °ª "
string ="I LOVE YOU"
$º¯¼ö¸í
[mageoli@howlinux mageoli]$ string="ILOVEYOU"
[mageoli@howlinux mageoli]$ echo $string
ILOVEYOU
[mageoli@howlinux mageoli]$ $string <-- º¯¼ö»ç¿ë
bash: ILOVEYOU: command not found <-- Ä¿¸Çµå°¡ ¾ø´Ù°í ³ª¿Â´Ù-_-;

½©°ú ¸î¸î À¯Æ¿¸®Æ¼ µéÀº ÇÊ¿äÇÑ °æ¿ì ¼öÄ¡°ªÀ» ¹®ÀÚ¿­·Î º¯È¯ÇÑ´Ù
À¯´Ð½º´Â ´ë¼Ò¹®ÀÚ ±¸º°ÀÌ Àֱ⠶§¹®¿¡, º¯¼ö¸í aaa,Aaa,AAA´Â
¸ðµÎ ´Ù¸£°Ô Ãë±Þ µÈ´Ù
º¯¼öÀÇ ³»¿ëÀ» º¸·Á¸é À§ÀÇ ¿¹Á¦Ã³·³ ¾ðÁ¦µçÁö º¯¼ö¸í ¾Õ¿¡ $À»
ºÙ¿©¼­ echo·Î È£ÃâÇÏ¸é µÈ´Ù
º¯¼ö¸¦ »ç¿ëÇÒ¶§´Â ¾ðÁ¦µçÁö $¸¦ ºÙÀÌÁö¸¸, º¯¼ö¿¡ °ªÀ» ÇÒ´çÇÒ ¶§´Â
$¸¦ ºÙÀÌÁö ¾Ê´Â´Ù (Áß¿ä!!!)
±×¸®°í º¯¼öÀÇ °ª¿¡ °ø¹éÀÌ Æ÷ÇÔµÇ¸é ¾ÕµÚ·Î µû¿ÈÇ¥·Î ¹­¾îÁÖ¾î¾ß ÇÑ´Ù.
¾Æ¿ï·¯ µîÈ£(=) ¾ÕµÚ¿¡ °ø¹éÀ» ³ÖÁö ¸»¾Æ¾ß ÇÑ´Ù´ÂÁ¡¿¡ ÁÖÀǸ¦ °¡Á®¾ßÇÑ´Ù

2. Àοëó¸®
º¸Åë, ÀÎÀÚ´Â °ø¹é¹®ÀÚ(½ºÆäÀ̽º,ÅÇ,´º¶óÀι®ÀÚ)·Î ±¸ºÐµÈ´Ù.
ÀÎÀÚ°¡ ÇϳªÀÌ»óÀÇ °ø¹é¹®ÀÚ¸¦ Æ÷ÇÔÇÑ´Ù¸é, ¹Ýµå½Ã ÀÎÀÚ¸¦ Àοëó¸®
ÇØ¾ß ÇÑ´Ù´Â °ÍÀ̸ç, º¯¼ö°ªÀ» Àοëó¸®ÇÒ ¶§ ¾î¶² ¹®ÀÚ¸¦ Àο빮ÀÚ·Î
»ç¿ëÇÏ´À³Ä¿¡ µû¶ó º¯¼öÀÇ ÇൿÀÌ ´Þ¶óÁö´Âµ¥, $º¯¼ö Ç¥ÇöÀ» Å«µû¿ÈÇ¥
(" ")¹­´Â´Ù¸é, º¯¼ö´Â º¯¼öÀÇ °ªÀ¸·Î ÀνĵÇÁö¸¸ ÀÛÀº µû¿ÈÇ¥(' ')
¹­´Â´Ù¸é º¯¼ö·Î¼­ ÀνÄÇÏÁö ¸øÇÏ°Ô µÈ´Ù
Å«µû¿ÈÇ¥¸¦ ¾ÈÇÏ°í ±×³É $º¯¼ö Ç¥ÇöÀ» »ç¿ëÇصµ ¹«¹æÇÏ°ÚÁö¸¸ ÀϹÝÀûÀ¸·Î
Å« µû¿ÈÇ¥·Î ¹­¾î¼­ ó¸®Çϸç, °ø¹é ¹®ÀÚ·Î ÀÎÇØ º¯¼öÀÇ °ªÀÌ ÂÉ°³Áö°Ô
µÇ´Â »óȲÀ» ¿¹¹æÇÒ¼ö ÀÖ´Ù. ±×¸®°í $Ç¥ÇöÀº ±× °ªÀ¸·Î ´ëüµÈ´Ù´Â
»ç½ÇÀÌ´Ï À¯³äÇÏ±æ ¹Ù¶õ´Ù

±×·³ º¯¼ö¿Í ÀοëºÎÈ£ÀÇ °ü°è¿¡ ´ëÇÑ ¿¹¸¦ º»´Ù

!/bin/sh

var="hello world"

echo $var
echo "$var"
echo '$var'
echo \$var
echo Enter some word
read overvar

echo '$othervar' now equals $othervar
exit 0

Á÷Á¢ Çѹø¾¿ ¿¡µðÅÍ·Î ÀÛ¼ºÇغ¸ÀÚ

[mageoli@howlinux mageoli]$ ./test.sh
./test.sh: !/bin/sh: No such file or directory
hello world
hello world
$var
$var
Enter some word

$othervar now equals

ÇÊÀÚ´Â ÀÌ·¸°Ô ¶á´Ù
°£·«È÷ ¼³¸íÇϸé var¶ó´Â º¯¼ö¿¡ hello world¸¦ ÀԷ½ÃÄÖ´Ù
echo·Î $var³ª "$var"´Â º° Â÷À̾øÀÌ Á¦´ë·Î ÀԷ½ÃŲ°©ÀÌ
Ãâ·ÂµÇ¾ú°í ³ª¸ÓÁö '$var'³ª #$var´Â ±×´ë·Î $var°¡ ¶¸´Ù
±×¸®°í read¸í·ÉÀº »ç¿ëÀÚÀÇ ÀÔ·ÂÀ»¹Þ´Â C¾ð¾î¿¡¼­ÀÇ
scanf¿Í °°Àº ±â´ÉÀ»ÇÏ´Â ¸í·É¾îÀÌ´Ù
ÀÌ·± º¯¼öµé ÀÌ¿Ü¿¡ ȯ°æº¯¼ö¿Í ÀÎÀÚº¯¼ö°¡ Àִµ¥ ¿©±â¿¡
´ëÇؼ­´Â ¸î°¡Áö¸¸ È®ÀÎÇÏ°í ³Ñ¾î°¡ÀÚ

-ȯ°æº¯¼ö-
$HOME : »ç¿ëÀÚÀÇ È¨ µð·ºÅ丮
$PATH : ¸í·É¾îÀÇ Ã£±â¿¡ »ç¿ëµÇ´Â ÄÝ·Ð(:)À¸·Î ±¸ºÐµÇ´Â
µð·ºÅ丮 ¸ñ·Ï
$0 : ½© ½ºÅ©¸³Æ®ÀÇ À̸§
$# : Àü´ÞµÈ ÀÎÀÚÀÇ °³¼ö
$$ : ½© ½ºÅ©¸³Æ®ÀÇ ÇÁ·Î¼¼½º ¾ÆÀ̵ð

-ÀÎÀÚº¯¼ö-
$1,$2... : ½ºÅ©¸³Æ®·Î Àü´ÞµÈ ÀÌÀÚ
$* : ½ºÅ©¸³Æ®·Î Àü´ÞµÈ ÀÌÀÚÀÇ Àüü·Î, ÇϳªÀÇ º¯¼ö¿¡
ÀúÀåµÈ´Ù.

ÀÌÁ¤µµ·Î¸¸ ¾Ë¾ÆµÎ±â·Î ÇÏ°í
ÀÎÀÚº¯¼ö¿Í ȯ°æº¯¼öÀÇ ¾²¿¥¿¡ ´ëÇØ ¾Ë¾Æº¸µµ·Ï ÇÏÀÚ

ex)
!/bin/sh

salutation="mageoil"
echo $salutation
echo "The program $0 is now running"
echo "The second parameter was $2"
echo "The first parameter was $1"
echo " "
echo "The parameter list was $*"
echo "The user's home directory is $HOME"
echo "Please enter a new greeting"
read salutation
echo $salutation
echo "The script is now complete"

Àá½Ã ¼³¸íÇÏÀÚ¸é, ¾Æ±îÀÇ ÇÁ·Î±×·¥Àº ½ÇÇà½Ã ÆÄÀÏÀ»
½ÇÇàÆÄÀÏ(chmod +x ÆÄÀÏÀ̸§)·Î ¸¸µç´ÙÀ½¿¡ ÆÄÀÏÀ» ½ÇÇà½ÃÄѺ¸ÀÚ
ÆÄÀÏÀ̸§À» ¸¸¾à ÀÌÆÄÀÏÀÇ ¸í·É¾î°¡ test¶ó°í ÇÏÀÚ.
test¸¸ ½ÇÇà½ÃÅ°¸é

mageoil
The program ./test2.sh is now running
The second parameter was
The first parameter was

The parameter list was
The user's home directory is /home/mageoli
Please enter a new greeting
ddd
ddd
The script is now complete
ÀÌ·¸°Ô ¶á´Ù..
µÚ¿¡ $1,$2,$* ¿¡ ¾Ï°Íµµ ¾ø´Â ÀÌÀ¯´Â.
´ÙÀ½ test¸¦ ½ÇÇà½ÃÄѺ¸¸é ¾Ë°ÍÀÌ´Ù
À̹ø¿£ test aaa bbb ccc ¶ó°í ½ÇÇà½ÃÄѺ¸ÀÚ
mageoil
The program ./test2.sh is now running
The second parameter was bbb
The first parameter was aaa

The parameter list was aaa bbb ccc
The user's home directory is /home/mageoli
Please enter a new greeting
ddd
ddd
The script is now complete

ÀÌÁ¦ Á¶±Ý¾¿Àº Â÷ÀÌÁ¡À» ´À³¢°í »ý°¢ÇØ º¸¸é ¾Ë°ÍÀÌ´Ù
À§¿¡Ã³·³ ½ÇÇà½Ãų¶§ $0Àº ÆÄÀÏÀ̸§À» ³ªÅ¸³ª°ÔµÇ°í
$1Àº aaa¸¦ $2´Â bbb, $3Àº ccc °¡ Ãâ·ÂµÇ¾úµû
±×¸®°í read´Â ¹«¾ùÀÎÁö Àú¹ø °­ÀÇ¿¡ ¸»Çß´Ù
´Ù½Ã ¸»ÇØ c¾ð¾îÀÇ scanf¿Í °°Àº ±â´ÉÀ̶ó°í ¸»ÇÒ¼öÀÖ´Ù

-- ¿À´ÃÀº ¿©±â ±îÁö¸¸ ÇÏ°Ô¾¸´Ù... ---

°ü·Ã±Û : ¾øÀ½ ±Û¾´½Ã°£ : 2002/01/23 0:27 from 202.30.55.60

  ½© ÇÁ·Î±×·¡¹Ö 2  [Á¦¾î±¸Á¶(if,elif) ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ ½©ÀÇ ±â´É°ú Ư¼º  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡