0
I would like to change a line when another line matchs under a section of a file using the sed command (or awk). Here is an exemple of the file :
Extract of MyFic.txt :
<PlayList>
... Some tags ...
<Album>X1</Album>
... oThers tags ...
<Group>X2</Group>
... Some tags ...
</PlayList>
<PlayList>
... Some tags ...
<Album>...</Album>
... oThers tags ...
<Group>...</Group>
... Some tags ...
</PlayList>
I would like to change the value of the tag Group by X3 when the tag Album value is X1 only into a PlayList section. The following command works fine :
sed -i '/< Album>X1/,/<\/PlayList>/ s/< Group>.*/< Group>X3<\/location>/' MyFic.txt
But this is not exactly what i really want. I would like someting like :
sed -i '/< PlayList>/,/<\/PlayList>/ {Containing < Album>X1} s/< Group>.*/< Group>X3<\/location>/' MyFic.txt
I don't know how to code this part with the sed command : {Containing < Album>X1}
Do you have some idea ?