There are several issues here:
1. The :a (label used for branching) does nothing in this context. Why is it there?
2. To replace ALL of the "~", you need the "g" flag--ie: sed 's/~/\t/g'
3. This construct: " sed <stuff> filename >> filename" Says: read from filename, apply the sed command, and append the result to filename. Thus, you wind up with the original content plus the modified content.
When I run it (with the g flag), the file winds up looking like this:
Code:
~ 4 ~ 2 ~ 4 ~
~ 11 ~ 2 ~ 4 ~
~ 2 ~ 2 ~ 4 ~
4 2 4
11 2 4
2 2 4
(Exactly what I would expect)
finally, the echo plus the command in backtics is not necessary---all you need is:
sed '<command>' file > newfile
OR
sed '<command>' file >> file