BBSˮľÇ廪վ¡Ã¾«»ªÇø

·¢ÐÅÈË: forest (ÇẮС¥~~ÐÄÖ¹), ÐÅÇø: Unix        
±ê  Ìâ: Îı¾´¦ÀíÃüÁîÖ® sed - cpu [ת] 
·¢ÐÅÕ¾: BBS Ë®Ä¾Ç廪վ (Tue Jan  4 17:52:16 2000) 
 
·¢ÐÅÈË: scz (СËÄ), ÐÅÇø: Solaris 
±ê  Ìâ: Îı¾´¦ÀíÃüÁîÖ® sed - cpu 
·¢ÐÅÕ¾: »ªÄÏÍøÄ¾ÃÞÕ¾ (Tue Jan  4 14:21:38 2000), ×ªÐÅ 
 
±êÌ⣺Îı¾´¦ÀíÃüÁîÖ® sed 
 
¹àË®µÄ¶¯»úºÜ¼òµ¥£¬98Äêµ×ËûÔÚ¸Ã°æ¸ø³öÁ½¸öshell±à³ÌʵսÁ·Ï°£¬ 
Ó¦ÕßÁÈÁÈ£¬¸Ð¿®Ö®ÖÐÌáµ½ÁËһϵÁÐÎı¾´¦ÀíÃüÁÄÇЩÃüÁîËäÈ»Âþ 
Ìì¶¼ÊÇ·ÉÎè×ÅmanÊֲᣬµ«²»Ò»¶¨ÄÜ¿ìËÙ¿´¶®£¬¼´Ê¹ÊÇÊìϤµÄÓû§£¬ 
Ò²Òªmanһϣ¬ÉÏÏ·­¹öÆÁÄ»ÏÔʾ£¬ËùÒÔÎҾͽè×Å»³ÄîµÄ³å¶¯Ò»Ò» 
¸ø³öËüÃǵÄʵÓþÙÀý£¬¾¡Á¿×öµ½Ò»Ä¿ÁËÈ»¡¢¼òµ¥ÊµÓ㬶ø²»ÊÇ·­Òë 
manÊֲᡣÒòΪÎÒÏÖÔÚÖ»ÓÐlinux»·¾³£¬ÎÞ·¨È¥solarisÉϲâÊÔ£¬½« 
¾ÍЩ£¬ÕâÖÖÃüÁî¶¼Êǹ㷺¼æÈݵ쬹àÔÚsolaris°æËƺõ²»¶ÔÍ·£¬¿É 
ÎÒÌÖÑálinux°æµÄÐúÏù£¬Ï²»¶ÍùÈÕsolaris°æµÄÕæ³ÏÈÈÇéÓëÖ±½ÓÃ÷ÁË£¬ 
Íû°ßÖñÊÖÏÂÁôÇé¡£´ËÍ⣬×Ô¼º¶ÔUnix²»ÊìϤ£¬¿ÉÄܳöÏÖ³¬¼¶Ð¦»°£¬ 
Âé·³ÐÖµÜÃÇÖ¸µã¡£ÎÄÕÂûÓйý¶à¸½¼ÓÏÞÖÆµØÔÊÐí×ªÔØÔÚ½ÌÓýÍø·¶Î§ 
ÄÚ£¬²»±ØÌá¼°Ô­×÷Õߣ¬Î¨Ò»ÐèÒªÌá¼°cpu£¬ÄÇÊǸö²»¸ÃÍü¼ÇµÄÐֵܡ£ 
 
²âÊÔ£º 
 
    ÒÔ Redhat6.0 Îª²âÊÔ»·¾³ 
    ÊÂʵÉÏÔÚsolarisϵÄsedÃüÁîÒª±ÈlinuxÇ¿£¬µ«ÒòΪûÓвâÊÔ 
    »·¾³£¬ÎÒÕâÀïÖ»¸øÔÚlinuxϾ­¹ý²âÊÔµÄÓ÷¨¡£ 
 
Ŀ¼£º 
 
    ¡ï ÃüÁîÐвÎÊý¼ò½é 
    ¡ï Ê×ÏȼÙÉèÎÒÃÇÓÐÕâÑùÒ»¸öÎı¾Îļþ sedtest.txt 
    ¡ï Êä³öÖ¸¶¨·¶Î§µÄÐРp 
    ¡ï ÔÚÿһÐÐÇ°ÃæÔö¼ÓÒ»¸öÖÆ±í·û(^I) 
    ¡ï ÔÚÿһÐкóÃæÔö¼Ó--end 
    ¡ï ÏÔʾָ¶¨Ä£Ê½Æ¥ÅäÐеÄÐкŠ[/pattern/]= 
    ¡ï ÔÚÆ¥ÅäÐкóÃæÔö¼ÓÎı¾ [/pattern/]a\ »òÕß [address]a\ 
    ¡ï É¾³ýÆ¥ÅäÐР[/pattern/]d »òÕß [address1][,address2]d 
    ¡ï Ì滻ƥÅäÐР[/pattern/]c\ »òÕß [address1][,address2]c\ 
    ¡ï ÔÚÆ¥ÅäÐÐÇ°Ãæ²åÈëÎı¾ [/pattern/]i\ »òÕß [address]i\ 
    ¡ï Ì滻ƥÅä´®(×¢Òâ²»ÔÙÊÇÆ¥ÅäÐÐ) [addr1][,addr2]s/old/new/g 
    ¡ï ÏÞ¶¨·¶Î§ºóµÄģʽƥÅä 
    ¡ï Ö¸¶¨Ì滻ÿһÐÐÖÐÆ¥ÅäµÄµÚ¼¸´Î³öÏÖ 
    ¡ï &´ú±í×îºóÆ¥Åä 
    ¡ï ÀûÓÃsedÐÞ¸ÄPATH»·¾³±äÁ¿ 
    ¡ï ²âÊÔ²¢Ìá¸ßsedÃüÁîÔËÐÐЧÂÊ 
    ¡ï Ö¸¶¨Êä³öÎļþ [address1][,address2]w outputfile 
    ¡ï Ö¸¶¨ÊäÈëÎļþ [address]r inputfile 
    ¡ï Ìæ»»ÏàÓ¦×Ö·û [address1][,address2]y/old/new/ 
    ¡ï !ºÅµÄʹÓà
    ¡ï \cÕýÔò±í´ïʽc µÄʹÓà
    ¡ï sedÃüÁîÖÐÕýÔò±í´ïʽµÄ¸´ÔÓÐÔ 
    ¡ï ×ª»»manÊÖ²á³ÉÆÕͨÎı¾¸ñʽ(ÐÂ) 
    ¡ï sedµÄmanÊÖ²á(ÓõľÍÊÇÉÏÃæµÄ·½·¨) 
 
¡ï ÃüÁîÐвÎÊý¼ò½é 
 
    sed 
    -e script Ö¸¶¨sed±à¼­ÃüÁî 
    -f scriptfile Ö¸¶¨µÄÎļþÖÐÊÇsed±à¼­ÃüÁî 
    -n ¼Å¾²Ä£Ê½£¬ÒÖÖÆÀ´×ÔsedÃüÁîÖ´Ðйý³ÌÖеÄÈßÓàÊä³öÐÅÏ¢£¬±ÈÈçÖ» 
       ÏÔʾÄÇЩ±»¸Ä±äµÄÐС£ 
 
    ²»Ã÷°×£¿²»Òª½ô£¬°ÑÕâЩ°¹Ôඪµ½Ò»±ß£¬¸úÎÒÍùÏÂ×ߣ¬²»¹ýÏÂÃæµÄ½éÉÜÀï 
    ²»°üÀ¨ÕýÔò±í´ïʽµÄ½âÊÍ£¬Èç¹ûÄã²»Ã÷°×£¬¿ÉÄÜÓеãÂé·³¡£ 
 
¡ï Ê×ÏȼÙÉèÎÒÃÇÓÐÕâÑùÒ»¸öÎı¾Îļþ sedtest.txt 
 
cat > sedtest.txt 
Sed is a stream editor 
---------------------- 
A stream editor is used to perform basic text transformations on an input stream 
-------------------------------------------------------------------------------- 
While in some ways similar to an editor which permits scripted edits (such as ed 


-------------------------------------------------------------------------------- 


sed works by making only one pass over the input(s), and is consequently more 
----------------------------------------------------------------------------- 
efficient. But it is sed's ability to filter text in a pipeline which particular 


-------------------------------------------------------------------------------- 

 
¡ï Êä³öÖ¸¶¨·¶Î§µÄÐРp other types of editors. 
 
sed -e "1,4p" -n sedtest.txt 
sed -e "/from/p" -n sedtest.txt 
sed -e "1,/from/p" -n sedtest.txt 
 
¡ï ÔÚÿһÐÐÇ°ÃæÔö¼ÓÒ»¸öÖÆ±í·û(^I) 
 
sed "s/^/^I/g" sedtest.txt 
 
×¢Òâ^IµÄÊäÈë·½·¨ÊÇctrl-v ctrl-i 
 
µ¥¸ö^±íʾÐÐÊ× 
 
¡ï ÔÚÿһÐкóÃæÔö¼Ó--end 
 
sed "s/$/--end/g" sedtest.txt 
 
µ¥¸ö$±íʾÐÐβ 
 
¡ï ÏÔʾָ¶¨Ä£Ê½Æ¥ÅäÐеÄÐкŠ[/pattern/]= 
 
sed -e '/is/=' sedtest.txt 
 

Sed is a stream editor 
---------------------- 

A stream editor is used to perform basic text transformations on an input stream 
-------------------------------------------------------------------------------- 
While in some ways similar to an editor which permits scripted edits (such as ed 


-------------------------------------------------------------------------------- 



sed works by making only one pass over the input(s), and is consequently more 
----------------------------------------------------------------------------- 

efficient. But it is sed's ability to filter text in a pipeline which particular 


-------------------------------------------------------------------------------- 


Òâ˼ÊÇ·ÖÎösedtest.txt£¬ÏÔʾÄÇЩ°üº¬is´®µÄÆ¥ÅäÐеÄÐкţ¬×¢Òâ11ÐÐÖгöÏÖÁËis×Ö·û´® 
Õâ¸öÊä³öÊÇÃæÏòstdoutµÄ£¬Èç¹û²»×öÖØ¶¨Ïò´¦Àí£¬Ôò²»Ó°ÏìÔ­À´µÄsedtest.txt 
 
¡ï ÔÚÆ¥ÅäÐкóÃæÔö¼ÓÎı¾ [/pattern/]a\ »òÕß [address]a\ 
^D 
 
sed -f sedadd.script sedtest.txt 
 
Sed is a stream editor 
 
A stream editor is used to perform basic text transformations on an input stream 
 
While in some ways similar to an editor which permits scripted edits (such as ed 


-------------------------------------------------------------------------------- 


sed works by making only one pass over the input(s), and is consequently more 
----------------------------------------------------------------------------- 
efficient. But it is sed's ability to filter text in a pipeline which particular 


-------------------------------------------------------------------------------- 


[scz@ /home/scz/src]> sed -e "a\\ 
+++++++++ 
--------------------------------------------- 
 
ÕÒµ½°üº¬from×Ö·û´®µÄÐУ¬ÔÚ¸ÃÐеÄÏÂÒ»ÐÐÔö¼Ó+++++++++¡£ 
Õâ¸öÊä³öÊÇÃæÏòstdoutµÄ£¬Èç¹û²»×öÖØ¶¨Ïò´¦Àí£¬Ôò²»Ó°ÏìÔ­À´µÄsedtest.txt 
 
ºÜ¶àÈËÏëÔÚÃüÁîÐÐÉÏÖ±½ÓÍê³ÉÕâ¸ö²Ù×÷¶ø²»ÊǶàÒ»¸ösedadd.script£¬²»ÐÒµÄÊÇ£¬ÕâÐèÒªÓõ 
½ 
ÐøÐзû\£¬ 
 
[scz@ /home/scz/src]> sed -e "/from/a\\ 
£¾ +++++++++" sedtest.txt 
 
[scz@ /home/scz/src]> sed -e "a\\ 
£¾ +++++++++" sedtest.txt 
 
ÉÏÃæÕâÌõÃüÁÔÚËùÓÐÐкóÔö¼ÓÒ»¸öÐÂÐÐ+++++++++ 
 
[scz@ /home/scz/src]> sed -e "1 a\\ 
£¾ +++++++++" sedtest.txt 
 
°ÑÏÂÃæÕâÁ½ÐÐcopy/pasteµ½Ò»¸öshellÃüÁîÐÐÉÏ£¬Ð§¹ûÒ»Ñù 
 
+++++++++" sedtest.txt 
 
[address]a\ Ö»½ÓÊÜÒ»¸öµØÖ·Ö¸¶¨ 
 
¶ÔÓÚaÃüÁ²»Ö§³Öµ¥ÒýºÅ£¬Ö»ÄÜÓÃË«ÒýºÅ£¬¶ø¶ÔÓÚdÃüÁîµÈÆäËûÃüÁͬʱ 
 
 
¡ï É¾³ýÆ¥ÅäÐР[/pattern/]d »òÕß [address1][,address2]d 
 
sed -e '/---------------------------------------------/d' sedtest.txt 
 
Sed is a stream editor 
 
A stream editor is used to perform basic text transformations on an input stream 
While in some ways similar to an editor which permits scripted edits (such as ed 


sed works by making only one pass over the input(s), and is consequently more 
efficient. But it is sed's ability to filter text in a pipeline which particular 

 

 
sed -e '6,10d' sedtest.txt 
ɾ³ý6-10ÐеÄÄÚÈÝ£¬°üÀ¨6ºÍ10 
 
sed -e "2d" sedtest.txt 
ɾ³ýµÚ2ÐеÄÄÚÈÝ 
 
sed "1,/^$/d" sedtest.txt 
ɾ³ý´ÓµÚÒ»Ðе½µÚÒ»¸ö¿ÕÐÐÖ®¼äµÄËùÓÐÄÚÈÝ 
×¢ÒâÕâ¸öÃüÁîºÜÈÝÒ×´øÀ´ÒâÍâµÄ½á¹û£¬µ±sedtest.txtÖдӵÚÒ»ÐпªÊ¼²¢Ã»ÓпÕÐУ¬Ôòsedɾ 
³ 
ý 
 
sed "1,/from/d" sedtest.txt 
ɾ³ý´ÓµÚÒ»Ðе½µÚÒ»¸ö°üº¬from×Ö·û´®µÄÐÐÖ®¼äµÄËùÓÐÄÚÈÝ£¬°üÀ¨µÚÒ»¸ö°üº¬ 
from×Ö·û´®µÄÐС£ 
 
¡ï Ì滻ƥÅäÐР[/pattern/]c\ »òÕß [address1][,address2]c\ 
 
sed -e "/is/c\\ 
**********" sedtest.txt 
 
ѰÕÒËùÓаüº¬is×Ö·û´®µÄÆ¥ÅäÐУ¬Ìæ»»³É********** 
 
********** 
---------------------- 
********** 
-------------------------------------------------------------------------------- 
While in some ways similar to an editor which permits scripted edits (such as ed 


-------------------------------------------------------------------------------- 


********** 
----------------------------------------------------------------------------- 
********** 
-------------------------------------------------------------------------------- 

 
sed -e "1,11c\\ 
**********" sedtest.txt---------------------- 
ÔÚ1-12ÐÐÄÚËÑË÷ËùÓÐfrom×Ö·û´®£¬·Ö±ðÌæ»»³É****×Ö·û´® 
 
¡ï ÏÞ¶¨·¶Î§ºóµÄģʽƥÅä 
 
sed "/But/s/is/are/g" sedtest.txt 
¶ÔÄÇЩ°üº¬But×Ö·û´®µÄÐУ¬°ÑisÌæ»»³Éare 
 
sed "/is/s/t/T/" sedtest.txt 
¶ÔÄÇЩ°üº¬is×Ö·û´®µÄÐУ¬°ÑÿÐеÚÒ»¸ö³öÏÖµÄtÌæ»»³ÉT 
 
sed "/While/,/from/p" sedtest.txt -n 
Êä³öÔÚÕâÁ½¸öģʽƥÅäÐÐÖ®¼äµÄËùÓÐÄÚÈÝ 
 
¡ï Ö¸¶¨Ì滻ÿһÐÐÖÐÆ¥ÅäµÄµÚ¼¸´Î³öÏÖ 
 
sed "s/is/are/5" sedtest.txt 
°ÑÿÐеÄis×Ö·û´®µÄµÚ5´Î³öÏÖÌæ»»³Éare 
 
¡ï &´ú±í×îºóÆ¥Åä 
 
sed "s/^$/(&)/" sedtest.txt 
¸øËùÓпÕÐÐÔö¼ÓÒ»¶Ô() 
 
sed "s/is/(&)/g" sedtest.txt 
¸øËùÓÐis×Ö·û´®ÍâÔö¼Ó() 
 
sed "s/.*/(&)/" sedtest.txt 
¸øËùÓÐÐÐÔö¼ÓÒ»¶Ô() 
 
sed "/is/s/.*/(&)/" sedtest.txt 
¸øËùÓаüº¬is×Ö·û´®µÄÐÐÔö¼ÓÒ»¶Ô() 
 
¡ï ÀûÓÃsedÐÞ¸ÄPATH»·¾³±äÁ¿ 
 
ÏȲ鿴PATH»·¾³±äÁ¿ 
[scz@ /home/scz/src]> echo $PATH 
/usr/bin:/usr/bin:/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/X11R6/bin:. 
 
È¥µôβ²¿µÄ{ :/usr/X11R6/bin:. } 
[scz@ /home/scz/src]> echo $PATH | sed "s/^\(.*\):\/usr[/]X11R6\/bin:[.]$/\1/" 
/usr/bin:/usr/bin:/bin:/usr/local/bin:/sbin:/usr/sbin 
 
È¥µôÖмäµÄ{ :/bin: } 
[scz@ /home/scz/src]> echo $PATH | sed "s/^\(.*\):\/bin:\(.*\)$/\1\2/" 
/usr/bin:/usr/bin/usr/local/bin:/sbin:/usr/sbin:/usr/X11R6/bin:. 
 
[/]±íʾ/Ê§È¥ÌØÊâÒâÒå 
\/ͬÑù±íʾ/ʧȥÒâÒå 
\1±íʾ×ÓÆ¥ÅäµÄµÚÒ»´Î³öÏÖ 
\2±íʾ×ÓÆ¥ÅäµÄµÚ¶þ´Î³öÏÖ 
\(.*\)±íʾ×ÓÆ¥Åä 
 
È¥µôβ²¿µÄ:£¬È»ºóÔö¼Óеķ¾¶ 
PATH=`echo $PATH | sed 's/\(.*\):$/\1/'`:$HOME/src 
×¢Òâ·´ÒýºÅ`ºÍµ¥ÒýºÅ'µÄÇø±ð¡£ 
 
¡ï ²âÊÔ²¢Ìá¸ßsedÃüÁîÔËÐÐЧÂÊ 
 
time sed -n "1,12p" webkeeper.db > /dev/null 
time sed 12q webkeeper.db > /dev/null 
¿ÉÒÔ¿´³öºóÕß±ÈǰÕßЧÂʸߡ£ 
 
[address]q µ±ÅöÉÏÖ¸¶¨ÐÐʱÍ˳ösedÖ´ÐР
 
¡ï Ö¸¶¨Êä³öÎļþ [address1][,address2]w outputfile 
 
sed "1,10w sed.out" sedtest.txt -n 
½«sedtest.txtÖÐ1-10ÐеÄÄÚÈÝдµ½sed.outÎļþÖС£ 
 
¡ï Ö¸¶¨ÊäÈëÎļþ [address]r inputfile 
 
sed "1r sedappend.txt" sedtest.txt 
½«sedappend.txtÖеÄÄÚÈݸ½¼Óµ½sedtest.txtÎļþµÄµÚÒ»ÐÐÖ®ºó 
 
¡ï Ìæ»»ÏàÓ¦×Ö·û [address1][,address2]y/old/new/ 
 
sed "y/abcdef/ABCDEF/" sedtest.txt 
½«sedtest.txtÖÐËùÓеÄabcdefСд×ÖÄ¸Ìæ»»³ÉABCDEF´óд×Öĸ¡£ 
 
¡ï !ºÅµÄʹÓà
 
sed -e '3,7!d' sedtest.txt 
ɾ³ý3-7ÐÐÖ®ÍâµÄËùÓÐÐР
 
sed -e '1,/from/!d' sedtest.txt 
ÕÒµ½°üº¬from×Ö·û´®µÄÐУ¬É¾³ýÆäºóµÄËùÓÐÐР
 
¡ï \cÕýÔò±í´ïʽc µÄʹÓà
 
sed -e "\:from:d" sedtest.txt 
µÈ¼ÛÓÚ sed -e "/from/d" sedtest.txt 
 
¡ï sedÃüÁîÖÐÕýÔò±í´ïʽµÄ¸´ÔÓÐÔ 
 
cat > sedtest.txt 
^\/[}]{.*}[\(]$\) 
^D 
 
ÈçºÎ²ÅÄܰѸÃÐÐÌæ»»³É 
\(]$\)\/[}]{.*}^[ 
 
¡ï ×ª»»manÊÖ²á³ÉÆÕͨÎı¾¸ñʽ(ÐÂ) 
 
man sed | col -b > sed.txt 
sed -e "s/^H//g" -e "/^$/d" -e "s/^^I/        /g" -e "s/^I/ /g" sed.txt > sedman 

txt 
ɾ³ýËùÓÐÍ˸ñ¼ü¡¢¿ÕÐУ¬°ÑÐÐÊ×µÄÖÆ±í·ûÌæ»»³É8¸ö¿Õ¸ñ£¬ÆäÓàÖÆ±í·ûÌæ»»³ÉÒ»¸ö¿Õ¸ñ¡£ 
 
¡ï sedµÄmanÊÖ²á(ÓõľÍÊÇÉÏÃæµÄ·½·¨) 
 
NAME 
       sed - a Stream EDitor 
SYNOPSIS 
       sed [-n] [-V] [--quiet] [--silent] [--version] [--help] 
           [-e script] [--expression=script] 
           [-f script-file] [--file=script-file] 
           [script-if-no-other-script] 
           [file...] 
DESCRIPTION 
       Sed  is a stream editor.  A stream editor is used to per- 
       form basic text transformations on an input stream (a file 
       or  input from a pipeline).  While in some ways similar to 
       an editor which permits scripted edits (such as ed),  sed 
       works  by  making  only one pass over the input(s), and is 
       consequently more efficient.  But it is sed's  ability  to 
       filter text in a pipeline which particularly distinguishes 
       it from other types of editors. 
OPTIONS 
       Sed  may  be  invoked  with  the  following   command-line 
       options: 
       -V 
       --version 
              Print  out the version of sed that is being run and 
              a copyright notice, then exit. 
       -h 
       --help Print a usage  message  briefly  summarizing  these 
              command-line options and the bug-reporting address, 
              then exit. 
       -n 
       --quiet 
       --silent 
              By default, sed will print out the pattern space at 
              the  end of  each cycle through the script.  These 
              options disable this automatic  printing,  and  sed 
              will  only  produce  output when explicitly told to 
              via the p command. 
       -e script 
       --expression=script 
              Add the commands in script to the set  of  commands 
              to be run while processing the input. 
       -f script-file 
       --file=script-file 
              Add  the commands contained in the file script-file 
              to the set of commands to be run while  processing 
              the input. 
       If  no  -e,-f,--expression, or --file options are given on 
       the command-line, then the first  non-option  argument  on 
       the command line is taken to be the script to be executed. 
       If any command-line parameters remain after processing the 
       above,  these  parameters  are interpreted as the names of 
       input files to be processed.  A file name of -  refers  to 
       the  standard  input stream.  The standard input will pro- 
       cessed if no file names are specified. 
Command Synopsis 
       This is just a brief synopsis of sed commands to serve  as 
       a reminder to those who already know sed; other documenta- 
       tion (such as the texinfo document) must be consulted  for 
       fuller descriptions. 
   Zero-address ``commands'' 
       : label 
              Label for b and t commands. 
       #comment 
              The  comment extends until the next newline (or the 
              end of a -e script fragment). 
       }      The closing bracket of a { } block. 
   Zero- or One- address commands 
       =      Print the current line number. 
       a \ 
       text   Append text, which has each embedded  newline  pre- 
              ceeded by a backslash. 
       i \ 
       text   Insert  text,  which has each embedded newline pre- 
              ceeded by a backslash. 
       q      Immediately quit the sed script without  processing 
              any  more  input,  except that if auto-print is not 
              diabled the current pattern space will be  printed. 
       r filename 
              Append text read from filename. 
   Commands which accept address ranges 
       {      Begin a block of commands (end with a }). 
       b label 
              Branch to label; if label is omitted, branch to end 
              of script. 
       t label 
              If a s/// has done a successful substitution  since 
              the  last  input line was read and since the last t 
              command, then branch to label; if label is omitted, 
              branch to end of script. 
       c \ 
       text   Replace  the  selected  lines  with text, which has 
              each embedded newline preceeded by a backslash. 
       d      Delete pattern space.  Start next cycle. 
       D      Delete up to the first embedded newline in the pat- 
              tern  space.   Start  next  cycle, but skip reading 
              from the input if there is still data in the  pat- 
              tern space. 
       h H    Copy/append pattern space to hold space. 
       g G    Copy/append hold space to pattern space. 
       x      Exchange the  contents  of  the hold  and pattern 
              spaces. 
       l      List out the current line in a ``visually unambigu- 
              ous'' form. 
       n N    Read/append the next line of input into the pattern 
              space. 
       p      Print the current pattern space. 
       P      Print up to the first embedded newline of the  cur- 
              rent pattern space. 
       s/regexp/replacement/ 
              Attempt  to match regexp against the pattern space. 
              If successful, replace that  portion  matched  with 
              replacement.   The replacement may contain the spe- 
              cial character & to refer to that  portion  of  the 
              pattern space  which  matched, and  the  special 
              escapes \1 through \9 to refer to the corresponding 
              matching sub-expressions in the regexp. 
       w      filename Write  the current pattern space to file- 
              name. 
       y/source/dest/ 
              Transliterate the characters in the  pattern  space 
              which appear in source to the corresponding charac- 
              ter in dest. 
Addresses 
       Sed commands can be given with no addresses, in which case 
       the command will be executed for all input lines; with one 
       address, in which case the command will only  be  executed 
       for  input  lines  which  match that address; or with two 
       addresses, in which case the command will be executed  for 
       all  input  lines which match the inclusive range of lines 
       starting from the first address and continuing to the sec- 
       ond  address.   Three things to note about address ranges: 
       the syntax is addr1,addr2 (i.e., the addresses  are  sepa- 
       rated  by  a  comma);  the  line  which addr1 matched will 
       always be accepted, even if addr2 selects an earlier line; 
       and  if addr2  is a regexp, it will not be tested against 
       the line that addr1 matched. 
       After the address (or address-range), and before the  com- 
       mand,  a !  may be inserted, which specifies that the com- 
       mand shall only be executed if the  address  (or  address- 
       range) does not match. 
       The following address types are supported: 
       number Match only the specified line number. 
       first~step 
              Match  every step'th line starting with line first. 
              For example, ``sed -n 1~2p''  will  print  all  the 
              odd-numbered  lines  in  the  input stream, and the 
              address 2~5 will match every fifth  line,  starting 
              with the second. (This is a GNU extension.) 
       $      Match the last line. 
       /regexp/ 
              Match lines matching the regular expression regexp. 
       \cregexpc 
              Match lines matching the regular expression regexp. 
              The c may be any character. 
Regular expressions 
       POSIX.2 BREs  should  be  supported, but they aren't com- 
       pletely yet.  The \n  sequence  in  a  regular  expression 
       matches the  newline  character.  There are also some GNU 
       extensions.  [XXX FIXME: more needs to be  said.   At  the 
       very   least,   a  reference  to  another  document  which 
       describes what is supported should be given.] 
Miscellaneous notes 
       This version of sed supports a \<newline> sequence in  all 
       regular expressions, the replacement part of a substitute 
       (s) command, and  in  the  source  and  dest  parts  of a 
       transliterate  (y)  command.   The  \ is stripped, and the 
       newline is kept. 
SEE ALSO 
       awk(1), ed(1), expr(1), emacs(1), perl(1),  tr(1),  vi(1), 
       regex(5) [well, one ought to be written... XXX], sed.info, 
       any of various books on sed, the sed FAQ 
       (http://www.wollery.demon.co.uk/sedtut10.txt, 
       http://www.ptug.org/sed/sedfaq.htm). 
BUGS 
       E-mail bug reports to bug-gnu-utils@gnu.org.  Be sure to 
       include the word ``sed'' somewhere in the ``Subject:'' 
       field. 
 
-- 
    ·ç ÊôÓÚÌìµÄ ÎÒ½èÀ´´µ´µ È´´µÆðÈ˼äÑÌ»ð 
    Ìì ÊôÓÚË­µÄ ÎÒ½èÀ´ÐÀÉÍ È´¿´µ½ÄãµÄÂÖÀª     
 
¡ù À´Ô´:¡¤BBS Ë®Ä¾Ç廪վ smth.org¡¤[FROM: 202.116.9.59] 

BBSˮľÇ廪վ¡Ã¾«»ªÇø