在Linux上,已經大部分都內建了。
在Windows上,請參閱此網站:
http://gnuwin32.sourceforge.net/packages/sed.htm
範例:
1. delete blank lines((刪除此行,當行為空白行)
sed -e /^$/d file
2. delete lines beginning with a tab(刪除此行,當行的開頭與一個tab字元)
/^ /d
3. delete lines beginning w/ any alpha characters,〈, or % (刪除此行,當行的開頭與一個任何一個字元)
/^[a-zA-Z\〈\%]/d
4. find lines beginning w/ one or more blanks, then print only the blanks(找到此行,當它的行開頭是一個或多個空白,然後只印出空白)
/^ */ {
s/^\( *\).*/\1/
}
5. delete all lines that just have ^M (need to do ^V ^M trick here)(刪除所有行,當它有 ^M)
/^^M$/d