I want use sed to replace a pattern.
- Go through each row
- Get each title, left of ":" (Line1) save its content "Line1_content"
- Check the "to be replaced part" on the right side of ":" in each row. find matched pattern "Line1" , and then replace it with saved content "Line1_content".
I prefer to use sed to save pattern and swap it to the matched part.
Example input:
Line1: content_A
Line2: content_B
Line3: Line1
Line4: nonsense & Line2
Example output:
Line1: content_A
Line2: content_B
Line3: content_A
Line4: nonsense & content_B
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…