:a - defines the label a
ta - If a s/// has done a successful substitution then branch to label 'a'
say.. in ya line
as ;;; as
so for the first time s/;;/;0;/;ta -> will successfully substitute to "as ;0;; as"
and it will branch to a again and will do make it "as ;0;0;as" and again branch to a.. now there is no substitution made, so will move to next line
But could you please elaborate. I am not able to understand. Whats the purpose of label here?
The example is also not clear to me.
Could you please explain?
sed -e 's/;;/;0;/g' -> the output will be sd;0;sd;0;;sd;0;;0;sd;0;;0;;sd
as u know sed is a line interperter and once a expression is found and replaced, it will start with the next character in the line.. i mean...
in ";;;" sed will match the first ";;" expression and will replace it to ";0;" and will start processing from the next character (which is the third ';' ) and thereby missing a '0' between 2nd and 3rd ';'
so in case of sed -e :a -e 's/;;/;0;/;ta'
when a branch is made back to position a, the search for expression will start from the beginning of the line rather than from the next character... so it will catch the 2nd and 3rd ;s now and will insert a zero between them...
Ok. As per my understanding the logic is as follows:
replace ;; with ;0; within a line untill all such possibilities are substituted. The line which is eligible for substitution is labelled as <Label-Name>
I wud rather say the position in the current line is labelled as <Label-Name>
since in my first -e i have just defined the label.. the position is the beginning of the line....