±¾°æ°æÖ÷ÕÐļÖÐ

 
±êÌâ: [ÒÉÎÊ] Çë½Ì£º½Å±¾ÖгöÏÖµÄ${DISK##*/}µÄº¬Òå
  ±¾Ö÷ÌâÓÉ ÀÏÅ© ÓÚ 2007-12-1 20:00 ÒÆ¶¯ 
xiaomage79
LUСÌìʹ
Rank: 3Rank: 3



UID 29022
¾«»ª 6
»ý·Ö 364
Ìû×Ó 559
»îÔ¾Ö¸Êý 236
LU½ð±Ò 3475 ¸ö
LU½ðÌõ 0 ¸ö
ÔĶÁȨÏÞ 20
×¢²á 2005-1-17
À´×Ô ÉϺ£
  ´ó ÖРС
·¢±íÓÚ 2007-12-1 19:57  ×ÊÁÏ  ¸öÈË¿Õ¼ä  ¶ÌÏûÏ¢  ¼ÓΪºÃÓÑ 
Çë½Ì£º½Å±¾ÖгöÏÖµÄ${DISK##*/}µÄº¬Òå

ÓÐÈçÏÂÒ»¶Î½Å±¾£º

echo "please input device name : \c"
read DISK
echo "${DISK##*/}"


ÔËÐÐʱ£¬ÊäÈë/dev/rdsk/c2t6d0
Êä³ö½á¹ûÊÇc2t6d0


½Å±¾ÖÐ${DISK##*/}²»Çå³þÊÇʲôº¬Ò壿£¿Çë´óϺÃǽâÊÍһϣ¿£¿





msn£ºxiaomage1979@msn.com
blog£ºhttp://www.loveunix.cn/index.php/29022/
         http://blog.chinaunix.net/u/23610/
¶¥²¿
zBS
¼¼Êõר¼Ò
Rank: 14Rank: 14Rank: 14Rank: 14



UID 36065
¾«»ª 1
»ý·Ö 35
Ìû×Ó 57
»îÔ¾Ö¸Êý 20
LU½ð±Ò 2182 ¸ö
LU½ðÌõ 0 ¸ö
ÔĶÁȨÏÞ 200
×¢²á 2005-11-2
  ´ó ÖРС
·¢±íÓÚ 2007-12-1 21:00  ×ÊÁÏ  ¸öÈË¿Õ¼ä  ¶ÌÏûÏ¢  ¼ÓΪºÃÓÑ  QQ
Äã¿ÉÒÔman bash»òÕßsh¿´¿´£¬ÏÂÃæÕâ¸öÊÇbashµÄ¡£    ÄãÕâ¸öµÄÒâ˼ÊÇ°É /Ç°ÃæµÄ*È«²¿½ØÈ¥¡£
   ${parameter}
              The value of parameter is substituted.  The braces are required when parameter is  a  positional  parameter
              with  more  than  one digit, or when parameter is followed by a character which is not to be interpreted as
              part of its name.

       If the first character of parameter is an exclamation point, a level of variable indirection is introduced.   Bash
       uses  the  value  of  the variable formed from the rest of parameter as the name of the variable; this variable is
       then expanded and that value is used in the rest of the substitution, rather than the value of  parameter  itself.
       This is known as indirect expansion.  The exception to this is the expansion of ${!prefix*} described below.

       In  each  of  the  cases below, word is subject to tilde expansion, parameter expansion, command substitution, and
       arithmetic expansion.  When not performing substring expansion, bash tests for a parameter that is unset or  null;
       omitting the colon results in a test only for a parameter that is unset.

       ${parameter:-word}
              Use  Default  Values.  If parameter is unset or null, the expansion of word is substituted.  Otherwise, the
              value of parameter is substituted.
       ${parameter:=word}
              Assign Default Values.  If parameter is unset or null, the expansion of word is assigned to parameter.  The
              value  of  parameter is then substituted.  Positional parameters and special parameters may not be assigned
              to in this way.
       ${parameter:?word}
              Display Error if Null or Unset.  If parameter is null or unset, the expansion of word (or a message to that
              effect  if  word  is not present) is written to the standard error and the shell, if it is not interactive,
              exits.  Otherwise, the value of parameter is substituted.
       ${parameter:+word}
              Use Alternate Value.  If parameter is null or unset, nothing is substituted,  otherwise  the  expansion  of
              word is substituted.
       ${parameterffset}
       ${parameterffset:length}
              Substring  Expansion.   Expands to up to length characters of parameter starting at the character specified
              by offset.  If length is omitted, expands to the substring of parameter starting at the character specified
              by  offset.   length  and offset are arithmetic expressions (see ARITHMETIC EVALUATION below).  length must
              evaluate to a number greater than or equal to zero.  If offset evaluates to a number less  than  zero,  the
              value is used as an offset from the end of the value of parameter.  If parameter is @, the result is length
              positional parameters beginning at offset.  If parameter is an array name indexed by @ or *, the result  is
              the  length  members  of  the  array beginning with ${parameter[offset]}.  Substring indexing is zero-based
              unless the positional parameters are used, in which case the indexing starts at 1.

       ${!prefix*}
              Expands to the names of variables whose names begin with prefix, separated by the first  character  of  the
              IFS special variable.

       ${#parameter}
              The  length in characters of the value of parameter is substituted.  If parameter is * or @, the value sub­
              stituted is the number of positional parameters.  If parameter is an array name subscripted by * or @,  the
              value substituted is the number of elements in the array.

       ${parameter#word}
       ${parameter##word}
              The word is expanded to produce a pattern just as in pathname expansion.  If the pattern matches the begin­
              ning of the value of parameter, then the result of the expansion is the expanded value  of  parameter  with
              the  shortest  matching pattern (the ‘â€?[1m#'' case) or the longest matching pattern (the ‘â€?[1m##'' case) deleted.
              If parameter is @ or *, the pattern removal operation is applied to each positional parameter in turn,  and
              the  expansion  is the resultant list.  If parameter is an array variable subscripted with @ or *, the pat­
              tern removal operation is applied to each member of the array in turn, and the expansion is  the  resultant
              list.

       ${parameter%word}
       ${parameter%%word}
              The word is expanded to produce a pattern just as in pathname expansion.  If the pattern matches a trailing
              portion of the expanded value of parameter, then the result of the  expansion  is  the  expanded  value  of
              parameter  with  the shortest matching pattern (the ‘â€?[1m%'' case) or the longest matching pattern (the ‘â€?[1m%%''
              case) deleted.  If parameter is @ or *, the pattern removal operation is applied to each positional parame­
              ter in turn, and the expansion is the resultant list.  If parameter is an array variable subscripted with @
              or *, the pattern removal operation is applied to each member of the array in turn, and  the  expansion  is
              the resultant list.

       ${parameter/pattern/string}
       ${parameter//pattern/string}
              The  pattern is expanded to produce a pattern just as in pathname expansion.  Parameter is expanded and the
              longest match of pattern against its value is replaced with string.  In the  first  form,  only  the  first
              match  is  replaced.  The second form causes all matches of pattern to be replaced with string.  If pattern
              begins with #, it must match at the beginning of the expanded value of parameter.  If pattern  begins  with
              %,  it must match at the end of the expanded value of parameter.  If string is null, matches of pattern are
              deleted and the / following pattern may be omitted.  If parameter is @ or *, the substitution operation  is
              applied  to each positional parameter in turn, and the expansion is the resultant list.  If parameter is an
              array variable subscripted with @ or *, the substitution operation is applied to each member of  the  array
              in turn, and the expansion is the resultant list.

¶¥²¿
meilixueshan
LUÓ×Ììʹ
Rank: 2



UID 45071
¾«»ª 0
»ý·Ö 172
Ìû×Ó 328
»îÔ¾Ö¸Êý 0
LU½ð±Ò 255 ¸ö
LU½ðÌõ 0 ¸ö
ÔĶÁȨÏÞ 20
×¢²á 2006-4-14
  ´ó ÖРС
·¢±íÓÚ 2007-12-2 05:21  ×ÊÁÏ  ¸öÈË¿Õ¼ä  ¶ÌÏûÏ¢  ¼ÓΪºÃÓÑ 
½Ø¶Ï×Ö·û´®
´Ó×ó±ß¿ªÊ¼µ½×îºóÒ»¸öÆ¥ÅäµÄ×Ö·û֮ǰµÄ×Ö·û¶¼±»¸Éµô£¡ºÇºÇ£¬ÈÆ¿ÚÁË
ÄãÉÏÃæµÄÀý×ÓËùҪƥÅäµÄ¾ÍÊÇ¡°/¡±
ËùÒÔ×îºóÒ»¸ö¡°/¡±Ö®Ç°µÄ×Ö·û´®£¬¶¼±»½ØµôÁË

¶¥²¿
xiaomage79
LUСÌìʹ
Rank: 3Rank: 3



UID 29022
¾«»ª 6
»ý·Ö 364
Ìû×Ó 559
»îÔ¾Ö¸Êý 236
LU½ð±Ò 3475 ¸ö
LU½ðÌõ 0 ¸ö
ÔĶÁȨÏÞ 20
×¢²á 2005-1-17
À´×Ô ÉϺ£
  ´ó ÖРС
·¢±íÓÚ 2007-12-2 11:30  ×ÊÁÏ  ¸öÈË¿Õ¼ä  ¶ÌÏûÏ¢  ¼ÓΪºÃÓÑ 
ллLSÖ¸µ¼£¬²éÔÄsh°ïÖú£¬µÃµ½ÈçϽâÊÍ

${parameter##pattern}

If the Shell pattern matches the beginning of the value of
the parameter, substitute the value of the parameter with
the matching pattern removed; otherwise substitute the
value of this parameter.  the largest matching pattern is deleted.





msn£ºxiaomage1979@msn.com
blog£ºhttp://www.loveunix.cn/index.php/29022/
         http://blog.chinaunix.net/u/23610/
¶¥²¿
 



µ±Ç°Ê±Çø GMT+8, ÏÖÔÚʱ¼äÊÇ 2008-8-21 21:09
ÀÖÓÆLoveUnixÂÛ̳£­¾©ICP±¸05005823ºÅ

Thanks to Discuz!  © 2001-2007    Power by LoveUnix.net
Processed in 0.068653 second(s), 7 queries , Gzip enabled

Çå³ý Cookies - ÁªÏµÎÒÃÇ - ÀÖÓÆLoveUnix - Archiver