I'm going to submit form using cURL, where some of the contents is come from other file, selected using sed
If param1
is line matching pattern from other file using sed
, below command will works fine:
curl -d param1="$(sed -n '/matchpattern/p' file.txt)" -d param2=value2 http://example.com/submit
Now, go to the problem. I want show only text between 2 matching pattern excluding the matching pattern itself.
Lets say file.txt
contains:
Bla bla bla
firstmatch
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
secondmatch
The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
Currently, lots of "beetween 2 matching pattern" sed
command won't remove firstmatch
and secondmatch
.
I want the result to become:
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
Best Answer
Here is one way you could do it:
Explained: From the first line to the line matching firstmatch, delete. From the line matching secondmatch to the last line, delete.