I have created a 0,1,2
genotype matrix and I want to replace all of the -1
with 9
.
0 0 -1 0 0 0 0 2 0 0 0 0 -1
0 0 1 0 0 0 0 0 0 0 0 -1 1
0 0 2 0 0 -1 2 0 0 0 -1 0 0
I tried this:
sed -ie 's/^[-1] /9 /' file1 > file2
but it seems that it does not work.
Is there any way to do that?
[]
enclose a collection of characters, so each occurrence of either-
or1
matches, but the^
anchors the expression to the beginning of the line, so you don't get any match. You also miss theg
flag to handle multiple occurences in a line. – Philippos Aug 3 '17 at 7:08