Skipping the first n lines when using regex with sed?

后端 未结 1 1428
青春惊慌失措
青春惊慌失措 2020-12-29 08:38

In sed, is it possible to skip the first n lines when applying a regex? I am currently using the following:

cat test | sed \'/^Name/d;/^--------         


        
相关标签:
1条回答
  • 2020-12-29 09:03

    Yes, you can apply sed commands to ranges of lines with the N,M syntax. In this case you want something like this:

    sed -e '2,$s/foo/bar/'
    

    An example with delete:

    sed -e '2,${ /^Name/d }'
    
    0 讨论(0)
提交回复
热议问题