Yong Ki/Abs Guide
1. µé¾î°¡¸é¼ ¶½©(shell)À̶ó´Â °Ç ÀÏÁ¾ÀÇ ¸í·É ÇØ¼®±âÀÔ´Ï´Ù. OS Ä¿³Î°ú »ç¿ëÀÚ »çÀÌÀÇ Áß°£ÀÚÀû ¿ªÇÒ ÀÌ»óÀ¸·Î ÇÁ·Î±×·¡¹Ö ¾ð¾î·Î¼ÀÇ ±â´É ¶ÇÇÑ °·ÂÇÏÁÒ. ½ºÅ©¸³Æ®(script)¶ó°íÇÏ´Â ½© ÇÁ·Î±×·¥Àº ½Ã½ºÅÛ ÄÝ, À¯Æ¿¸®Æ¼, ÀÌÁøÆÄÀÏ µîÀ» ¼·Î ºÙÀÌ°í ¿¬°áÇØ¼ ¼Õ½±°Ô ÀÀ¿ëÇÁ·Î±×·¥À» °³¹ßÇϵµ·Ï µµ¿ÍÁÖ´Â ÅøÀ̶ó°í º¸½Ã¸é µË´Ï´Ù. »ç½Ç»ó ¸ðµç UNIX ¸í·É¾î, À¯Æ¿¸®Æ¼, Åø µîÀÌ ½ºÅ©¸³Æ®ÀÇ Àç·á°¡ µÉ ¼ö ÀÖ½À´Ï´Ù¸¸ À̰ÍÀ¸·Îµµ ÃæºÐÄ¡ ¾Ê´Ù¸é ½© ³»ºÎÀÇ Á¶°Ç¹®, ¹Ýº¹¹® µî ¿©·¯ ±¸¹®µéÀ» ¾²½Å´Ù¸é ½ºÅ©¸³Æ®°¡ Á»´õ °·ÂÇϰí À¯¿¬ÇØÁö°Ú³×¿ä. ½© ½ºÅ©¸³Æ®´Â ½Ã½ºÅÛ °ü¸®(admin) ÀÛ¾÷À̳ª µ¢Ä¡ Å« ÇÁ·Î±×·¡¹Ö ¾ð¾î±îÁö´Â ÇÊ¿äÇÏÁö ¾ÊÀº ·çƾ ¹Ýº¹ÀûÀÎ ÀÛ¾÷¿¡ ƯÈ÷ ´É·ÂÀ» ¹ßÈÖÇÕ´Ï´Ù.
1.1. ¿Ö ½© ÇÁ·Î±×·¡¹ÖÀΰ¡? ¶¼÷·ÃµÈ ½Ã½ºÅÛ °ü¸®ÀÚ¿¡°Ô ÀÖ¾î¼ ½© ½ºÅ©¸³ÆÃ Áö½ÄÀº ÇʼöÀÔ´Ï´Ù. ½ºÅ©¸³Æ® ÀÛ¼ºÇÒ ÀÏÀÌ ¾ø´Ù°í »ý°¢ÇÏ´Â °ü¸®ÀÚ¿¡°Ôµµ ¿¹¿Ü¾øÁÒ. ¾Æ½Ã´Ù½ÃÇÇ ¸®´ª½º ½Ã½ºÅÛÀÌ ºÎÆÃÇÒ ¶§
/etc/rc.d ¿¡ ÀÖ´Â ½ºÅ©¸³Æ®µéÀ» ½ÇÇàÇØ¼ ½Ã½ºÅÛ ¼³Á¤À» º¹¿øÇÏ°í ¼ºñ½ºµéÀ» ¼¼ÆÃÇÕ´Ï´Ù. ½Ã½ºÅÛÀÇ µ¿Å¸¦ ºÐ¼®ÇÏ°í ¼öÁ¤ÇÏ·Á¸é ÀÌ·± ½Ãµ¿(startup) ½ºÅ©¸³Æ®µéÀ» ¼¼ºÎÀûÀ¸·Î ÀÌÇØÇØ¾ß°ÚÁÒ.
½© ½ºÅ©¸³Æ®¸¦ ÀÛ¼ºÇÏ´Â °ÍÀº ±×¸® ¾î·ÆÁö ¾Ê½À´Ï´Ù. ½ºÅ©¸³Æ®´Â ÇÑÀ԰Ÿ®ÀÇ ºÎºÐµé·Î Â¥Áý±â µÇ¾î ÀÖ°í ½© °íÀ¯ÀÇ ¿¬»êÀÚ³ª ¿É¼Çµé[1]µµ ¸¹Áö ¾Ê±â ¶§¹®ÀÌÁÒ. ¹®¹ýµµ ´Ü¼øÇϰí Á÷°üÀûÀÌ¸ç ¸í·ÉÇà »ó¿¡¼ À¯Æ¿¸®Æ¼µéÀ» ½ÇÇàÇÏ°í ¿¬°áÇÏ´Â ¹æ½Ä°ú ºñ½ÁÇÕ´Ï´Ù. ÀÍÇô¾ß ÇÒ ±ÔÄ¢(rule)µµ ±×¸® ¸¹Áö ¾Ê¾Æ¿ä.
º¹ÀâÇÑ ÀÀ¿ëÇÁ·Î±×·¥ÀÇ ÇÁ·ÎÅäŸÀÔ(prototype)À» ÀÛ¼ºÇÏ´Â µ¥ "quick and dirty"ÇÑ ¹æ¹ýÀ¸·Î ½© ½ºÅ©¸³Æ®°¡ ÀÌ¿ëµÇ±âµµ ÇÕ´Ï´Ù. ÇÁ·ÎÁ§Æ® °³¹ßÀÇ Ã¹ ´Ü°è·Î¼ ºÎºÐÀûÀ¸·Î ±â´ÉÀ» ±¸ÇöÇÏ´Â µ¥ ½©½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÏ¿© Å×½ºÆ®ÇÏ¸é¼ C, C++, Java ³ª Perl µîÀ¸·Î ÃÖÁ¾ ÄÚµùµÇ±â Àü¿¡ ·çƾÀÇ ±¸Á¶Àû ȤÀº ³í¸®Àû °áÇÔÀÌ ¹ß°ßµÇÁÒ.
½© ½ºÅ©¸³ÆÃÀº º¹ÀâÇÑ ÇÁ·ÎÁ§Æ®´Â ´õ ´Ü¼øÇÑ ¿ä¼Òµé·Î ³ª´²¼ ÀÛ¾÷ÇÏ°í ´Ù½Ã °áÇÕÇÑ´Ù´Â °íÀüÀûÀÎ UNIX öÇÐÀ» Àß ÀÌÇàÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù. ¸¹Àº »ç¶÷µéÀÌ Â÷¼¼´ëÀÇ ¿ÃÀοø(all-in-one) °í±Þ ¾ð¾î¸¦ »ç¿ëÇÏ´Â °Íº¸´Ù´Â ÀÌ·¯ÇÑ ¹æ½ÄÀÌ ´õ ÁÁ°Å³ª ¸Å·ÂÀûÀ̶ó°í »ý°¢ÇÏÁÒ. ¸ðµç »ç¶÷¿¡°Ô ¸ðµç ÀÏÀÌ °¡´ÉÇϵµ·Ï ±âȹµÈ ±×·± ¾ð¾î¸¦ »ç¿ëÇÏ·Á¸é ÀÚ½ÅÀÇ »ç°í¹æ½Ä°ú ÀýÂ÷¸¦ ±× µµ±¸¿¡ ¸Â°Ô °íÃÄ¾ß ÇÏ´Â ºÎ´ãÀº °¨¼öÇØ¾ß ÇÕ´Ï´Ù.
´ÙÀ½ÀÇ ÀÛ¾÷À» ÇÒ »ý°¢À̶ó¸é ½© ½ºÅ©¸³Æ®´Â Àû´çÇÏÁö ¾Ê½À´Ï´Ù.
¿ì¸®°¡ ¾ÕÀ¸·Î ÇÔ²² ¹è¿öº¼ ½©Àº BashÀÔ´Ï´Ù. Bash´Â "Bourne-Again shell"ÀÇ ¸Ó¸´±ÛÀÚÀ̰í Stephen BourneÀÇ Bourne Shell¿¡¼ À¯·¡ÇßÁÒ. Bash´Â »ç½Ç»ó °ÅÀÇ ¸ðµç UNIX(-like)¿¡¼ ½©½ºÅ©¸³ÆÃÀÇ Ç¥ÁØÀÌ µÇ¾ú½À´Ï´Ù. ¾ÕÀ¸·Î ¾ê±âÇÒ ´ëºÎºÐÀÇ ¿ø¸®µéÀº Korn Shell[2]À̳ª C Shell°ú °°Àº ´Ù¸¥ ½©¿¡¼ÀÇ ½ºÅ©¸³ÆÃ¿¡µµ Àû¿ëÇØ º¼ ¼ö ÀÖ¾î¿ä. (C Shell ÇÁ·Î±×·¡¹ÖÀº ÃßõÇÏÁö ¾Ê½À´Ï´Ù. 1993³â 10¿ù¿¡ Tom Christiansen ÀÌ C ShellÀÇ Å¸°í³ °áÇÔ¿¡ ´ëÇØ À¯Áî³Ý¿¡ Æ÷½ºÆ®Çß¾ú³×¿ä.)
À̾îÁú ³»¿ëÀº ½© ½ºÅ©¸³ÆÃ Æ©Å丮¾ó(tutorial)ÀÔ´Ï´Ù. ½©ÀÇ ´Ù¾çÇÑ Æ¯Â¡µéÀ» ¼³¸íÇϱâ À§ÇØ ¸¹Àº ¿¹Á¦µéÀ» °çµé¿´´Âµ¥ ¸î¸îÀº ±×´ë·Î °¡Á®´Ù ½áµµ À¯¿ëÇÑ °ÍµéÀÌÁÒ. ¿¹Á¦ ½ºÅ©¸³Æ®ÀÇ ¼Ò½ºÆÄÀÏ(
scriptname.sh ¶Ç´Â scriptname.bash )[3]À» ½ÇÇàÇÏ·Á¸é ¸ÕÀú chmod u+rx scriptname °ú °°ÀÌ ½ÇÇàÆÛ¹Ì¼ÇÀ» ÁÖ¾î¾ß ÇÑ´Ù´Â °Í ÀØÁö ¸¶¼¼¿ä.
1.2. Sha-Bang(#!)À¸·Î ½ÃÀÛÇÏÀÚ ¶°¡Àå °£´ÜÇÑ ½ºÅ©¸³Æ®¸¦ º¸¸é, ½ºÅ©¸³Æ®¶ó´Â °ÍÀº ½Ã½ºÅÛ ¸í·É¾îµéÀ» ÆÄÀÏ ¾È¿¡ ³ª¿ÇÑ °Í¿¡ Áö³ªÁö ¾Ê±¸³ª ÇÏ´Â »ý°¢ÀÌ µé°Ì´Ï´Ù. ±×·¸´Ù°í ÇØµµ ½ÇÇàÇÒ ¶§¸¶´Ù µ¿ÀÏÇÑ ¸í·É¾îµéÀ» ´Ù½Ã ŸÀÌÇÎÇÏ´Â ¼ö°í´Â ´ú¾îÁÖ´Â °ÅÁÒ.
¿¹Á¦ 2-1. cleanup : /var/log ¾È¿¡ ÀÖ´Â ·Î±×ÆÄÀÏ Ã»¼ÒÇÏ´Â ½ºÅ©¸³Æ®
# Cleanup
# Run as root, of course.
cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
echo "Logs cleaned up."
¿¹Á¦ 2-2. cleanup : °³¼±µÈ clean-up ½ºÅ©¸³Æ®
#!/bin/bash
# Proper header for a Bash script.
# Cleanup, version 2
# Run as root, of course.
# Insert code here to print error message and exit if not root.
LOG_DIR=/var/log
# Variables are better than hard-coded values.
cd $LOG_DIR
cat /dev/null > messages
cat /dev/null > wtmp
echo "Logs cleaned up."
exit # The right and proper method of "exiting" from a script.
¿¹Á¦ 2-3. cleanup : À§ ½ºÅ©¸³Æ®¸¦ °ÈÇϰí ÀϹÝÈÇÑ ¹öÀü
#!/bin/bash
# Cleanup, version 3
# Warning:
# -------
# This script uses quite a number of features that will be explained
#+ later on.
# By the time you've finished the first half of the book,
#+ there should be nothing mysterious about it.
LOG_DIR=/var/log
ROOT_UID=0 # Only users with $UID 0 have root privileges.
LINES=50 # Default number of lines saved.
E_XCD=66 # Can't change directory?
E_NOTROOT=67 # Non-root exit error.
# Run as root, of course.
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $E_NOTROOT
fi
if [ -n "$1" ]
# Test if command line argument present (non-empty).
then
lines=$1
else
lines=$LINES # Default, if not specified on command line.
fi
# Stephane Chazelas suggests the following,
#+ as a better way of checking command line arguments,
#+ but this is still a bit advanced for this stage of the tutorial.
#
# E_WRONGARGS=65 # Non-numerical argument (bad arg format)
#
# case "$1" in
# "" ) lines=50;;
# *[!0-9]*) echo "Usage: `basename $0` file-to-cleanup"; exit $E_WRONGARGS;;
# * ) lines=$1;;
# esac
#
#* Skip ahead to "Loops" chapter to decipher all this.
cd $LOG_DIR
if [ `pwd` != "$LOG_DIR" ] # or if [ "$PWD" != "$LOG_DIR" ]
# Not in /var/log?
then
echo "Can't change to $LOG_DIR."
exit $E_XCD
fi # Doublecheck if in right directory, before messing with log file.
# far more efficient is:
#
# cd /var/log || {
# echo "Cannot change to necessary directory." >&2
# exit $E_XCD;
# }
tail -$lines messages > mesg.temp # Saves last section of message log file.
mv mesg.temp messages # Becomes new log directory.
# cat /dev/null > messages
#* No longer needed, as the above method is safer.
cat /dev/null > wtmp # ': > wtmp' and '> wtmp' have the same effect.
echo "Logs cleaned up."
exit 0
# A zero return value from the script upon exit
#+ indicates success to the shell.
½ºÅ©¸³Æ® ¸Ç óÀ½¿¡ µîÀåÇÏ´Â sha-bang(#!)Àº ¾Æ·¡ÀÇ ½ºÅ©¸³Æ®´Â ÁöÁ¤ÇÑ ¸í·É ÇØ¼®±â¸¦ ÅëÇØ¼ ¼öÇàµÇ¾î¾ß ÇÑ´Ù´Â °É ½Ã½ºÅÛ¿¡ ¾Ë·ÁÁÖ´Â ¿ªÇÒÀ» ÇÕ´Ï´Ù. #! ´Â »ç½Ç 2¹ÙÀÌÆ®[4] ¸ÅÁ÷³Ñ¹ö(magic number, ÀÚ¼¼ÇÑ ³»¿ëÀº man magicÀ» Ãĺ¸¼¼¿ä)ÀÔ´Ï´Ù. sha-bang ´ÙÀ½¿¡´Â °ð¹Ù·Î °æ·Î¸íÀÌ ¿Í¾ß Çϴµ¥, ½ºÅ©¸³Æ®¿¡ ¾²ÀÎ ¸í·ÉµéÀ» ÇØ¼®ÇÒ ÇÁ·Î±×·¥ °æ·ÎÀÌ°í ½©, ÇÁ·Î±×·¡¹Ö ¾ð¾î ¶Ç´Â À¯Æ¿¸®Æ¼ µîÀÌ ¿Ã ¼ö ÀÖ¾î¿ä. sha-bang¶óÀÎÀÇ ´ÙÀ½ ÁÙºÎÅʹ ȣÃâµÈ ¸í·É ÇØ¼®±â°¡ ¼øÂ÷ÀûÀ¸·Î 󸮸¦ Çϰí, À̶§ ÁÖ¼®(comments)Àº ¹«½ÃÇÕ´Ï´Ù.[5]
#!/bin/bash #!/usr/bin/perl #!/usr/bin/tcl #!/bin/sed -f #!/usr/awk -fÀ§ÀÇ sha-bang¶óÀεéÀº °¢±â ´Ù¸¥ ¸í·É ÇØ¼®±â¸¦ È£ÃâÇϴϱî ÇÊ¿äÇÑ ´ë·Î Çϳª¸¸ ¼±ÅÃÇϼ¼¿ä. ´ëºÎºÐÀÇ »ó¾÷ÀûÀÎ UNIX·ùÀÇ ¿î¿µÃ¼Á¦¿¡¼ ±âº»(default)À¸·Î äÅÃÇϰí ÀÖ´Â #!/bin/shÀ» »ç¿ëÇÑ´Ù¸é ½ºÅ©¸³Æ®¸¦ ºñ¸®´ª½º ¸Ó½Å¿¡ À̽ÄÇÒ ¼ö ÀÖ°Ô µË´Ï´Ù. ¹°·Ð Bash °íÀ¯ÀÇ Æ¯Â¡µéÀº ¸ø ¾²°ÚÁö¸¸ ½ºÅ©¸³Æ®´Â POSIX[6] shÇ¥ÁØÀ» µû¸£°Ô µÇ´Â °ÅÁÒ. sha-bang¶óÀÎÀÇ °æ·Î¸íÀº À¯È¿ÇÑ °ÍÀ̾î¾ß ÇÕ´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é ¿¡·¯ ¸Þ¼¼Áö(º¸Åë "Command not found")¸¸ µþ¶û ³»º¸³»°Åµç¿ä.
½© ³»ºÎÀÇ ¸í·ÉµéÀ» »ç¿ëÇÏÁö ¾Ê°í ÀϹÝÀûÀÎ ½Ã½ºÅÛ ¸í·Éµé¸¸ Âß ³ª¿ÇÑ ½ºÅ©¸³Æ®¶ó¸é(À§ÀÇ Ã¹¹øÂ° ¿¹Á¦Ã³·³) #!¶óÀÎÀ» »ý·«ÇÒ ¼ö ÀÖ½À´Ï´Ù. À§ÀÇ µÎ¹øÂ° ¿¹Á¦¿¡¼´Â ½© °íÀ¯ÀÇ ±¸¹®ÀÎ º¯¼ö ÇÒ´ç¹®(lines=50)À» »ç¿ëÇ߱⠶§¹®¿¡ ¹Ýµå½Ã #!¶óÀÎÀ» ½á¾ß ÇÏÁÒ. ¶Ç Çϳª ¸í½ÉÇÒ °ÍÀº #!/bin/shÀº ±âº»(default) ½©À» ½ÇÇàÇÕ´Ï´Ù. ¸®´ª½º ¸Ó½Å¿¡¼´Â
/bin/bash °¡ ±âº» ½©ÀÌ¿¡¿ä.
![]()
E_WRONG_ARGS=65
script_parameters="-a -h -m -z"
# -a = all, -h = help, etc.
if [ $# -ne $Number_of_expected_args ]
then
echo "Usage: `basename $0` $script_parameters"
# `basename $0` is the script's filename.
exit $E_WRONG_ARGS
fi
1.2.1. ½ºÅ©¸³Æ® ½ÇÇàÇϱ⠶½ºÅ©¸³Æ®¸¦ ÀÛ¼ºÇßÀ¸¸é sh scriptname[7]³ª bash scriptnameÀ» Ãļ ½ÇÇàÇØ º¸¼¼¿ä. (Not recommended is using sh
chmod 555 scriptname (¸ðµç »ç¿ëÀÚ¿¡°Ô Àбâ/½ÇÇà ÆÛ¹Ì¼ÇÀ» ºÎ¿©ÇÕ´Ï´Ù.)[8]
¶Ç´Â
chmod +rx scriptname (À§¿Í °°½À´Ï´Ù.)
À̳ª
chmod u+rx scriptname (ÆÄÀÏ ¼ÒÀ¯ÀÚ¿¡°Ô¸¸ Àбâ/½ÇÇà ÆÛ¹Ì¼ÇÀ» ºÎ¿©ÇÕ´Ï´Ù.)
ÀÌ·¸°Ô Çϸé ./scriptname[9]¸¦ Ãļ ½ÇÇàÇÒ ¼ö ÀÖ¾î¿ä. ¹°·Ð, ½ºÅ©¸³Æ®°¡ sha-bang¶óÀÎÀÌ ÀÖÀ¸¸é ÁöÁ¤µÈ ¸í·É ÇØ¼®±â¸¦ È£ÃâÇØ¼ ½ÇÇàÇÕ´Ï´Ù.
½ºÅ©¸³Æ®ÀÇ Å×½ºÆ®¿Í µð¹ö±ëÀÌ ³¡³ª°í ¿Ï¼ºµµ°¡ ³ô¾ÆÁø ÈÄ root±ÇÇÑÀ¸·Î ½ºÅ©¸³Æ® ÆÄÀÏÀ»
/usr/local/bin À¸·Î ¿Å±â¸é, ¸í·ÉÇà¿¡¼ scriptname¸¦ Ä¡´Â °Í¸¸À¸·Îµµ ½ºÅ©¸³Æ®¸¦ ½ÇÇàÇÒ ¼ö ÀÖ°Ô µÇ°í ´Ù¸¥ »ç¿ëÀڵ鵵 ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
1.2.2. ¿¬½À ¹®Á¦ ¶
2.1. Ư¼ö ¹®ÀÚ ¶½ºÅ©¸³Æ®³ª ±âŸ °÷°÷¿¡¼ ÀÚÁÖ º¸À̴ Ư¼ö¹®ÀÚµé
#
ÁÖ¼®(comments). # ¿¡¼ºÎÅÍ ÁÙ ³¡±îÁö´Â ÁÖ¼®Ã³¸® ÇÕ´Ï´Ù. # ¾Õ¿¡ °ø¹éÀÌ ¿Íµµ µÇÁÒ.
;
# This line is a comment.
echo "A comment will follow." # Comment here.
# ^ Note whitespace before #
# A tab precedes this comment.
![]() ![]()
echo "The # here does not begin a comment."
echo 'The # here does not begin a comment.'
echo The \# here does not begin a comment.
echo The # here begins a comment.
echo ${PATH#*:} # Parameter substitution, not a comment.
echo $(( 2#101011 )) # Base conversion, not a comment.
# Thanks, S.C.
¸í·É ±¸ºÐÀÚ [semicolon]. ÇÑÁÙ¿¡ µÑ ÀÌ»óÀÇ ¸í·É¹®ÀÌ °¡´ÉÇÏ°Ô ÇÏÁÒ.
echo hello; echo there
if [ -x "$filename" ]; then # Note that "if" and "then" need separation.
# Why?
echo "File $filename exists."; cp $filename $filename.bak
else
echo "File $filename not found."; touch $filename
fi; echo "File test complete."
case ±¸¹®¿¡¼ ¼±Åù® Á¾°áÀÚ [double semicolon].
.
case "$variable" in
abc) echo "\$variable = abc" ;;
xyz) echo "\$variable = xyz" ;;
esac
"dot" command [period]. Equivalent to source (see Example 11-20). This is a bash builtin.
.
"dot", ÆÄÀÏ¸í¿¡¼. ÆÄÀϸíÀÌ "."À¸·Î ½ÃÀÛÇÏ¸é ¼û±èÆÄÀÏÀÌ µË´Ï´Ù.
.
bash$ touch .hidden-file bash$ ls -l total 10 -rw-r--r-- 1 bozo 4034 Jul 18 22:04 data1.addressbook -rw-r--r-- 1 bozo 4602 May 25 13:58 data1.addressbook.bak -rw-r--r-- 1 bozo 877 Dec 17 2000 employment.addressbook bash$ ls -al total 14 drwxrwxr-x 2 bozo bozo 1024 Aug 29 20:54 ./ drwx------ 52 bozo bozo 3072 Aug 29 20:51 ../ -rw-r--r-- 1 bozo bozo 4034 Jul 18 22:04 data1.addressbook -rw-r--r-- 1 bozo bozo 4602 May 25 13:58 data1.addressbook.bak -rw-r--r-- 1 bozo bozo 877 Dec 17 2000 employment.addressbook -rw-rw-r-- 1 bozo bozo 0 Aug 29 20:54 .hidden-fileµð·ºÅ丮¸íÀ» ´ë½ÅÇØ ¾µ ¼öµµ Àִµ¥, "."Àº ÇöÀç µð·ºÅ丮¸¦, ".."Àº »óÀ§ µð·ºÅ丮¸¦ ÀǹÌÇÕ´Ï´Ù. bash$ pwd /home/bozo/projects bash$ cd . bash$ pwd /home/bozo/projects bash$ cd .. bash$ pwd /home/bozo/"."Àº ÆÄÀÏÀ» À̵¿½ÃŰ´Â ¸í·É¿¡¼ ¸ñÀûÁö(µð·ºÅ丮)¸¦ ´ë½ÅÇØ¼ ÀÚÁÖ ¾²ÀÔ´Ï´Ù. bash$ cp /home/bozo/current_work/junk/* . "dot", Á¤±ÔÇ¥Çö½Ä¿¡¼. Á¤±ÔÇ¥Çö½Ä¿¡¼ "."Àº ¹®ÀÚ Çϳª¿¡ ¸ÅÄ¡µË´Ï´Ù.
"
partial quoting [double quote]. "STRING" preserves (from interpretation) most of the special characters within STRING. See also Chapter 5.
'
full quoting [single quote]. 'STRING' preserves all special characters within STRING. This is a stronger form of quoting than using ". See also Chapter 5.
,
ÄÞ¸¶(comma) ¿¬»êÀÚ. ÄÞ¸¶ ¿¬»êÀÚ´Â ÀÏ·ÃÀÇ ¼öÄ¡ ¿¬»êÀ» ¿¬°áÇÕ´Ï´Ù. ¿¬°áµÈ ¿¬»ê½Ä ¸ðµÎ¸¦ Æò°¡ÇÏÁö¸¸ ¸¶Áö¸· °Í¸¸ ¹ÝÈ¯ÇØ¿ä.
\
let "t2 = ((a = 9, 15 / 3))" # Set "a = 9" and "t2 = 15 / 3"
À̽ºÄÉÀÌÇÁ ¹®ÀÚ [backslash]. A quoting mechanism for single characters.
/
\X "escapes" the character X. This has the effect of "quoting" X, equivalent to 'X'. The \ may be used to quote " and ', so they are expressed literally. See Chapter 5 for an in-depth explanation of escaped characters ÆÄÀÏ¸í °æ·Î ±¸ºÐÀÚ [forward slash].
`
/home/bozo/projects/Makefile ó·³ ÆÄÀÏ¸í¿¡¼ ±¸ºÐÀÚ ¿ªÇÒÀ» Çϴµ¥, »ê¼ú¿¡¼ ³ª´°¼À ¿¬»êÀڷεµ ¾²ÀÌÁÒ.
command ġȯ backquote, backtick. `·Î °¨½Ñ command´Â commandÀÇ Ãâ·Â¹°À» º¯¼ö¿¡ ´ëÀÔÇÒ ¶§ ÀÌ¿ëÇÕ´Ï´Ù.
:
null command [colon]. "NOP" (no op, a do-nothing operation)¿Í °°½À´Ï´Ù. ½© ³»ÀåÀÇ true¿Í µ¿ÀǾî·Î º¸½Ã¸é µË´Ï´Ù. ":" Àº ±× ÀÚü·Î ¾²ÀÏ ¼ö ÀÖ°í exit°ªÀº "true" (0)ÀÔ´Ï´Ù.
:
echo $? # 0
while :
do
operation-1
operation-2
...
operation-n
done
# Same as:
# while true
# do
# ...
# done
if condition
then : # Do nothing and branch ahead
else
take-some-action
fi
: ${username=`whoami`}
# ${username=`whoami`} Gives an error without the leading :
# unless "username" is a command or builtin...
----
|
His heart was yours from the first moment that you met. |