1

I have the following text..

[start]
this
is my line
[end]

My output should be:

this
is my line

Need help..

Tried a combination of :

sed -n '/start/,/end/p' $File  & sed -e "s/]/']/" -e "s/\[/['/"   $file

but it brings up the pattern too.

veekay
  • 11

2 Answers2

0

You can remove the first and last line with

$ sed '1d;$d'

So of your input file just include the text you've shown you are done. If you need to find the part between [start] and [end] do it like this:

$ sed -n '/start/,/end/p' $File | sed '1d;$d'
0

Does this satisfy your requirement?

sed -n '/^[start]/,/[end]/p'

The equivalent to the above is:

sed '/^[start]/,/[end]/!d'