このシナリオで置換を使用する方法を知りたいです。以下のように、 myfile.txtとresponsefile.txtという 2 つのファイルがあります。
myfile.txt
user=myname
user_1=yourname
group=mygroup
group_1=yourgroup
応答ファイル.txt
#Please fill the user id details.
user=
#user_1=
#Please fill the group id details.
group=
#group_1=
ここで、上記の 2 つのファイルを使用して、一致するパターンを置き換えた後、次の最終結果を得たいと考えています。responsefile.txt の内容はそのままで、一致したパターンに myfile.txt で提供される詳細を前に付けるか、パターンが両方のファイルで同じであるため、一致する行全体のみを置き換える必要があります。
responsefile.txt (新しいファイルを置換/パターンで置換)
#Please fill the user id details.
user=myname
user_1=yourname
#Please fill the group id details.
group=mygroup
group_1=yourgroup
パターンはハッシュなしまたはハッシュ付きであるため、一致時にハッシュを削除する必要があります。ファイル responsefile.txt の長さは約 604L、16481C であることに注意してください。
実際のシナリオのコンテンツには 100 以上の類似パターンがあるため、簡単な解決策が必要です。上記は一例です。
ありがとうラージェッシュ