sedã¯ä¸ããããæååãï¼ã«ã¼ã«ã«å¾ã£ã¦å¤æããã³ãã³ãã ãä¾ãã°ï¼æååã®ç½®æï¼è¡ã®åé¤ã¨ãã£ãå¦çãè¡ããã å¤æã«å©ç¨ã§ããã«ã¼ã«ã«ã¯ä¸è¡¨ãsedã®æ¡ä»¶å¼ãã®ãããªæ¡ä»¶å¼ãå©ç¨ã§ãããä¾ãã°ï¼æååãæ¿å ¥ãããå ´åã¯ãaãããiãã®å¾ã«æ¿å ¥ããæååãæå®ãããæååãç½®æãããå ´åã¯ãs/ç½®æã«ã¼ã«/ç½®ææå/ãã¨å®è¡ããã ç½®æã«ã¼ã«ã®æåã«æ°å¤ãæå®ããã¨ï¼æå®ããè¡ã®ã¿ãå¦çããããä¾ãã°ï¼ã3dãã¨æå®ããã¨ï¼3è¡ç®ãåé¤ãããã sedã³ãã³ãã§å®éã«å¤æãè¡ãå ´åã¯ï¼å¤æå¦çå 容ã¯ã-eããªãã·ã§ã³ãæå®ããå¾ã«è¨è¿°ãããã¾ãï¼sedã³ãã³ãã«æå®ãããã¡ã¤ã«ã®å 容ãå¦çãããä¾ãã°ï¼source.txtå ã®Linuxããªããã¯ã¹ã«ç½®æãããå ´åã¯ï¼æ¬¡ã®ããã«å®è¡ããã $ sed -e "s/Linux/ãªããã¯ã¹/g" source.txt çµæã¯æ¨æºåºåï¼ãã£ã¹
â ãã¤ãã§ãã£ã«ã¿ã«å å·¥ããããã¼ã¿ãåã渡ããç®çã¨ããæååãæ½åºãããã£ã«ã¿ãªã³ã°å¦çãè¡ãã ãã¤ãã使ç¨ãã¦ä¸å¿ è¦ãªæååãæ¶å»ãããã¾ãã¯é©åãªä½ç½®ã«æååãä»å ãããã¨ãã£ããã£ã«ã¿ãæã¿è¾¼ããã¨ã§ç®çã¨ãããã¼ã¿ãæ½åºããã ã¾ãããã£ã«ã¿ããã¤ãã§è¤æ°é£çµãããã¨ã§ãããè¤éãªãã£ã«ã¿ãªã³ã°å¦çãå®ç¾ãããã¨ãã§ããã sed ã³ãã³ãã使ç¨ãããã£ã«ã¿ãªã³ã° æåå A ãæåå B ã«ç½®æãã sed ã³ãã³ãã¯ãã¾ãã¾ãªæ©è½ãæã£ãã³ãã³ãã ãã主ã«ã¯æååã®ç½®æå¦çã«å©ç¨ãããã³ãã³ãã§ãããç½®æå¦çãè¡ãå ´åã«ã¯ãç½®æ対象ã¨ç½®æå¾ã®æååãæå®ãã¦ã³ãã³ããå®è¡ãããç½®æ対象ã®æå®ã«ã¯ä¸é¨ã®æ£è¦è¡¨ç¾ã使ç¨ãããã¨ãå¯è½ã§ãã (ä¸é¨ã®æ£è¦è¡¨ç¾ã¯ä½¿ç¨ã§ããªããã¾ããsed ã®ãã¼ã¸ã§ã³çã«ãã使ç¨ã§ããæ£è¦è¡¨ç¾ãç°ãªã)ã åè¡ã®æåã«ä¸è´ããæååã®ã¿ç½®æ â
sedï¼ã»ãï¼ã¯ãå ¥åã¹ããªã¼ã ï¼ãã¡ã¤ã«ã¾ãã¯ãã¤ãã©ã¤ã³ããã®å ¥åï¼ã«å¯¾ãã¦ããã¹ãå¤æãªã©ã®ãã¼ã¿å¦çããããªãããã«ä½¿ç¨ãããããã°ã©ã ã§ãããå称ãsedãã¯ãã¹ããªã¼ã ã¨ãã£ã¿ããæå³ããè±èªãstream editorãã«ç±æ¥ãã[1]ã sedã¯ãå ¥åãè¡åä½ã§èªã¿åããsedã¹ã¯ãªããã¨å¼ã°ããã·ã³ãã«ãªå½ä»¤æã«å¾ã£ã¦ããã¹ãå¤æãªã©ã®ç·¨éããããªããã¾ãè¡åä½ã§åºåãã[1]ãåºæ¬çã«ã¯ç §åã«ã¼ã«ã«å¾ãå ´ååãããããªããã£ã«ã¿ã¨æãããã¨ãã§ããããªãªã¸ãã«çã®sedã¯ãã«ç 究æã®ãã¯ããã³ã«ãã£ã¦1973å¹´åå¾ã«éçºãããUNIXã¦ã¼ãã£ãªãã£[2][1][3]ã§ãç¾å¨ã§ã¯ã³ãã³ãã©ã¤ã³ããµãã¼ããããã¾ãã¾ãªãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã«æè¼ããã¦ãã[1]ã 大éã®ããã¹ããã¡ã¤ã«ã«å¯¾ãã¦ä¸æ¬ã§å®å½¢ã®å¦çããããªãå ´åã«å¤§ããªå¨åãçºæ®ãããæ£è¦è¡¨ç¾ã«å¯¾å¿ãã¦ããã
sed sed ã¨ã¯ Stream EDitor ã®ç¥ã§åºæ¬çã«æååç½®æã®ããã«ä½¿ç¨ããã³ãã³ãã§ãï¼ä»ã«ãããã¤ãã®æ©è½ãããã¾ãï¼ã ä¾ãã°ã % sed 's/ika/tako/' [filename] ã¨ããã¨ã[filename] ã§æå®ãããã¡ã¤ã«ä¸ã®æåã«è¦ã¤ãã£ã ika ã¨ããæååã tako ã«å¤ãã¦ãæ¨æºåºåã«åºåãã¾ãã åºåããã¡ã¤ã«ã«ä¿åãããå ´åã¯ãªãã¤ã¬ã¯ããå©ç¨ãã¦ã % sed 's/ika/tako/' [in_file] > [out_file] ã®ããã«ãã¾ãããã¡ã¤ã«ãã®ãã®ãæ¸ãæãã¦ãã¾ãããå ´åã¯ã % sed -i 's/ika/tako/g' [filename] ã®ããã« -i ãªãã·ã§ã³ã使ç¨ãã¾ãã-i[SUFFIX]ãä¾ãã° -i.bak ã®ããã«ããã¨ã[filename].bak ã®ãããªããã¯ã¢ãããã¨ã£ã¦ããã¦ããã¾
sedã¨awkã¯ãUNIXã®ä¸çã§ãã·ã¹ãã 管çãããã°ã©ãã³ã°ãåããå¿ é ã®ãã¼ã«ã¨ããã¾ããæ¬æ¸ã¯ããã®2ã¤ã®ãã¼ã«ã®è§£èª¬æ¸ã¨ãã¦å®çªã®æ¸ç±ã§ããæ¹è¨ã«ããã£ã¦ã¯ãPOSIXã«å¯¾å¿ããããã®ä¿®æ£ãææ°ã®sedãawkã®ãã¼ã¸ã§ã³ã«ã¤ãã¦ã®å çä¿®æ£ã¯ãã¡ããã®ãã¨ãæ¬æã®è¦ç´ãããã¾ãããããã«ãããã¤ãã®å¸è²©awkãããªã¼ã½ããã¦ã§ã¢ã®awkã«ã¤ãã¦ã®è§£èª¬ã追å ãã¾ããã æ£èª¤è¡¨ ããã§ç´¹ä»ããæ£èª¤è¡¨ã«ã¯ãæ¸ç±çºè¡å¾ã«æ°ã¥ãã誤æ¤ãæ´æ°ãããæ å ±ãæ²è¼ãã¦ãã¾ãã以ä¸ã®ãªã¹ãã«è¨è¼ã®å¹´æã¯ãæ£èª¤è¡¨ãä½æããå¢å·æ¸ç±ãå°å·ããæã§ãããææã¡ã®æ¸ç±ã§ã¯ããã§ã«ä¿®æ£ãæ½ããã¦ããå ´åãããã¾ãã®ã§ãæ¸ç±æçµãã¼ã¸ã®å¥¥ä»ã§ãææã¡ã®æ¸ç±ã®å·çãå·ãå¹´ææ¥ãã確èªã®ä¸ããå©ç¨ãã ããã æ£èª¤è¡¨1 ----- 1999å¹´7æ ãsed & awkããã°ã©ãã³ã° æ¹è¨çã æ£èª¤è¡¨ ãã®æ£èª¤è¡¨ã¯ç¬¬1
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}