LinuxÒÁµéÔ°ÂÛ̳'s Archiver

walkright ·¢±íÓÚ 2007-8-24 12:37

Çë½Ì sedÌí¼Ó×Ö·û´®¸ÃÔõôд£¿

ÈçÏ£¬Õâ¸ö½Å±¾ÊÇ´íÎóµÄ£¬Ö»ÊÇÏë˵Ã÷Ò»ÏÂÎÒÏëÓýű¾×öʲô¡£

#!/bin/sh

module=" "

for((i=0; i<$*; i++))
do
    module=sed -i "s/$module/$module test$i"
done

echo $module

ÎÒ×îºóÏëµÃµ½
module= test0 test1 test2 test3........

¸ÃÔõôʵÏÖÄØ£¿

walkright ·¢±íÓÚ 2007-8-24 12:40

ÔÚÏߵȽâ´ð£¬Ð»Ð»ÁË:)

walkright ·¢±íÓÚ 2007-8-24 12:57

̫ɵÁË£¬ÕâÑù¾Í¿ÉÒÔʵÏÖÁË

[root@server buffer_pool]# cat -n test.sh
     1  #!/bin/sh
     2
     3  module=" "
     4
     5  for((i=0; i<$*; i++))
     6  do
     7      module="$module test$i"
     8  done
     9
    10  echo $module
[root@server buffer_pool]# sh test.sh 5
test0 test1 test2 test3 test4

dearvoid ·¢±íÓÚ 2007-8-24 13:12

[quote]Ô­ÌûÓÉ [i]walkright[/i] ÓÚ 2007-8-24 12:57 ·¢±í [url=http://www.linuxeden.com/forum/redirect.php?goto=findpost&pid=581852&ptid=158391][img]http://www.linuxeden.com/forum/images/common/back.gif[/img][/url]
̫ɵÁË£¬ÕâÑù¾Í¿ÉÒÔʵÏÖÁË

[root@server buffer_pool]# cat -n test.sh
     1  #!/bin/sh
     2
     3  module=" "
     4
     5  for((i=0; i [/quote]
good :)

040410615 ·¢±íÓÚ 2007-10-8 20:38

ºÎ±Ø:) ½«ÎÊÌ⸴ÔÓ»°ÄØ  
СµÜÈÏΪ·Ç³£¼òµ¥
modle=$*
echo "modle=$modle"
¼´¿É

li-jiahuan ·¢±íÓÚ 2007-10-8 22:54

[quote]Ô­ÌûÓÉ [i]walkright[/i] ÓÚ 2007-8-24 12:57 ·¢±í [url=http://www.linuxeden.com/forum/redirect.php?goto=findpost&pid=581852&ptid=158391][img]http://www.linuxeden.com/forum/images/common/back.gif[/img][/url]
̫ɵÁË£¬ÕâÑù¾Í¿ÉÒÔʵÏÖÁË

[root@server buffer_pool]# cat -n test.sh
     1  #!/bin/sh
     2
     3  module=" "
     4
     5  for((i=0; i [/quote]

$* ÊÇÖ¸ËùÓеÄλÖòÎÊý
$1 Ó¦¸Ã²ÅÊÇwalkrightÏëÒªµÄ°É

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.