For example I have this text:
<<<<<<<<< <<source_dir>>
tesst
<<<<<<<<< <<target_dir>>
tes23442141
<<<<<<<<<
good
safasf
<<<<<<<<< <<source_dir>>
tesst241241
<<<<<<<<< <<target_dir>>
tes23442141
<<<<<<<<<
safasfas
And section is
<<<<<<<<< <<source_dir>>
[any text -> first text]
<<<<<<<<< <<target_dir>>
[any text -> second text]
<<<<<<<<<
And I want replace all this section to only first text
For example output must be:
tesst
good
safasf
tesst241241
safasfas
I have this sed :
sed -e ':a;N;$!ba;s#<<<<<<<<< <<source_dir>>n(.*)n<<<<<<<<< <<target_dir>>.*<<<<<<<<<#1#g' "$target_file"
But as output I have:
tesst
<<<<<<<<< <<target_dir>>
tes23442141
<<<<<<<<<
good
safasf
<<<<<<<<< <<source_dir>>
tesst241241
safasfas
And question how I can fix it?)
I understand the problem but I don’t understand how to do it>
Please help me!