Next: pattern/hold space, 多regex條件與script檔
Up: sed
Previous: 簡介
  Contents
address是sed裡的特殊用語,用來設定符合條件的行,以便對它執行編輯命令,
符合條件的條件指定方法有1. range(範圍) 2.regular express。
sed的address除了之前regular expression介紹的
1,3 . $ %這種表示法外 還可以直接用 /regex/找到要的行
$ sed '2d' file 找到第二行幹掉
$ sed '/delete/d' file 找到delete這個字幹掉整行
$ sed '/RE/,$d' file 從有RE字眼的行到檔案尾通通幹掉
$ sed '/^$/d' file 幹掉空白行
$ sed '/START/,/END/!s/xx/yy/g' file > file1 把xx換成yy
Cyril Huang
2002-06-14