ÔõÑùʹÓà sed Ìí¼ÓÐУ¿¼±ÓÃ
[root@server buffer_pool]# cat -n testa1
2 c=0
3 b=2
4 a=0
5 d=1
6 f=5
[root@server buffer_pool]# cat -n test.sh
1 #!/bin/sh
2
3 cat -n testa
4
5 for((i=0; i<$*; i++))
6 do
7 sed "///" testa
8 done
9
10 cat -n testa
[root@server buffer_pool]# sh test.sh 5
ÎÒÏëʹÓÃÕâ¸ö½Å±¾ÊµÏÖ
[root@server buffer_pool]# cat -n testa
1
2 c=0
3 b=2
4 a=0
5 a=1
6 a=2
7 a=3
8 a=4
9 d=1
10 f=5
ÇëÎÊÓ¦¸ÃÔõôÓà sed ʵÏÖ £¿ [quote][font=Courier][color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[16167 0][/color] [color=red]; echo $'aa\nbb'
[/color]aa
bb
[color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[16167 0][/color] [color=red]; echo $'aa\nbb' | sed -e $'/bb/i\\\ncc'
[/color]aa
cc
bb
[color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[16167 0][/color] [color=red]; bye
[/color][/font][/quote] лл£¬
¿ÉÔõô½«Ð޸ı£´æµ½ÎļþÀïÄØ£¿ [quote][font=Courier][color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[16167 0][/color] [color=red]; echo hello world > file
[/color][color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[16167 0][/color] [color=red]; cat file
[/color]hello world
[color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[16167 0][/color] [color=red]; bye
[/color][/font][/quote] ÓÖѧ»áÁËÁ½µã£¬¶àл°æÖ÷:lol ÎÒÕâÑùдµÄ£¬
sed -i $"/d=1/i\\\ a=$i" testa
Ò²¿ÉÒÔ±£´æ [quote]ÔÌûÓÉ [i]walkright[/i] ÓÚ 2007-8-24 13:58 ·¢±í [url=http://www.linuxeden.com/forum/redirect.php?goto=findpost&pid=581868&ptid=158395][img]http://www.linuxeden.com/forum/images/common/back.gif[/img][/url]
ÎÒÕâÑùдµÄ£¬
sed -i $"/d=1/i\\\ a=$i" testa
Ò²¿ÉÒÔ±£´æ [/quote]
good :) Çë½Ìdearvoid
sed -e $'///' ÖÐµÄ "$"ΪºÎÒ⣿ ÎÒÊǽèÖúÒ»¸öÁÙʱÎļþʵÏÖµÄ:) [quote]ÔÌûÓÉ [i]li-jiahuan[/i] ÓÚ 2007-8-25 13:22 ·¢±í [url=http://www.linuxeden.com/forum/redirect.php?goto=findpost&pid=581933&ptid=158395][img]http://www.linuxeden.com/forum/images/common/back.gif[/img][/url]
Çë½Ìdearvoid
sed -e $'///' ÖÐµÄ "$"ΪºÎÒ⣿ [/quote]
bash µÄ manual Õâô˵:
[font=Courier][code]
Words of the form $'string' are treated specially. The word expands to
string, with backslash-escaped characters replaced as specified by the
ANSI C standard. Backslash escape sequences, if present, are decoded
as follows:
\a alert (bell)
\b backspace
\e an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\' single quote
\nnn the eight-bit character whose value is the octal value
nnn (one to three digits)
\xHH the eight-bit character whose value is the hexadecimal
value HH (one or two hex digits)
\cx a control-x character
The expanded result is single-quoted, as if the dollar sign had not
been present.
[/code][/font]
For example:
[quote][font=Courier][color=black][/color][color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[$$=1282 $?=0][/color] [color=red]; echo 'hello\nworld'
[/color][color=black]hello\nworld
[/color][color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[$$=1282 $?=0][/color] [color=red]; echo $'hello\nworld'
[/color][color=black]hello
world
[/color][color=blue]-(dearvoid@LinuxEden:Forum)-(~/tmp)-
[$$=1282 $?=0][/color] [color=red]; bye
[/color][color=black][/color][/font][/quote]
[[i] ±¾Ìû×îºóÓÉ dearvoid ÓÚ 2007-10-9 18:05 ±à¼ [/i]] ͵ѧһÕÐ
dearvoid¶ÔÄÐÈË¿´µÃÕæ×Ðϸ°¡:lol [quote]ÔÌûÓÉ [i]li-jiahuan[/i] ÓÚ 2007-10-9 19:36 ·¢±í [url=http://www.linuxeden.com/forum/redirect.php?goto=findpost&pid=588714&ptid=158395][img]http://www.linuxeden.com/forum/images/common/back.gif[/img][/url]
dearvoid¶ÔÄÐÈË¿´µÃÕæ×Ðϸ°¡:lol [/quote]
²»½âºÎÒâ :(
»Ø¸´ #12 dearvoid µÄÌû×Ó
²»ÊÇ˵"man"Âð£¿ÄѵÀ²»ÊÇÄÐÈË£¿:lolÅ®°æÖ÷µÄ»°¿ÉÄÜÊǷdz£Ï²»¶µÄÓ´~
[[i] ±¾Ìû×îºóÓÉ fitren ÓÚ 2007-10-10 09:30 ±à¼ [/i]]
Ò³:
[1]