cURLを使用して他のファイルから取得したコンテンツを含むフォームを送信します。sed
param1
別のファイルの行一致パターンを使用すると、sed
次のことが正常に動作します。
curl -d param1="$(sed -n '/matchpattern/p' file.txt)" -d param2=value2 http://example.com/submit
それでは、トラブルシューティングを始めましょう。一致するパターン自体ではなく、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 like readable English.
現在、多くの "beetween 2 match pattern"コマンドはおよびをsed
削除しません。firstmatch
secondmatch
私は結果が次のようになりたいです。
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
ベストアンサー1
これを行うための1つの方法は次のとおりです。
sed '1,/firstmatch/d;/secondmatch/,$d'
説明: 最初の行から一致する行まで最初のゲーム、削除。ラインマッチングの観点からセカンドゲーム最後の行に行き、削除してください。