sed 命令

将 log 文件中,以 Time 开头的行,输出到 time.log

sed -n '/^Time/p' log > time.log 

将 log 文件中,以 ) 结尾的行,输出到 fo.log

sed -n '/)$/p' log > fo.log 

单引号之间 /)$/p 为命令,/ 为分隔符,) 表明需要查找的字符是 ),$ 表示行尾,^ 则表示行开头。

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see


This site uses Akismet to reduce spam. Learn how your comment data is processed.