edで2番目に表示される単語/構文を置き換えます。

edで2番目に表示される単語/構文を置き換えます。

edで2番目/3番目の単語/構文のみを置き換える構文は何ですか?

He wanted to buy groceries from the shop, but preferred not having to go into the shop. >>
He wanted to buy groceries from the shop, but preferred not having to go into it. >>

ベストアンサー1

ed、の代替コマンドは、s///コマンド文字列の末尾にゼロ個以上のフラグを使用します。フラグに正の整数が含まれている場合N、置換が適用されます。N:最初のゲーム。

the shop現在の行で2番目に表示される部分文字列を文字列に置き換えたいと仮定すると、it次のようになります。

s/the shop/it/2

編集セッションのスナップショットは次のとおりです。ここで、ユーザーは現在の行を表示してpから2番目の項目を変更することを決定し、the shop編集後に行を再表示します(次を使用)。p バナーコマンドs///):

p
He wanted to buy groceries from the shop, but preferred not having to go into the shop.
s/the shop/it/2p
He wanted to buy groceries from the shop, but preferred not having to go into it.

編集コマンドのこの機能はs///継承されますsed

おすすめ記事