我将使用 cURL 提交表单,其中一些内容来自其他文件,使用选择 sed
如果param1
使用来自其他文件的行匹配模式sed
,下面的命令将正常工作:
curl -d param1="$(sed -n '/matchpattern/p' file.txt)" -d param2=value2 http://example.com/submit
Run Code Online (Sandbox Code Playgroud)
现在,去解决问题。我只想显示 2 个匹配模式之间的文本,不包括匹配模式本身。
可以说file.txt
包含:
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 …
Run Code Online (Sandbox Code Playgroud)