Reputation: 4135
Input:
These are some numbers aklö0/4:asfasd;assdf...asf8/8asdfklöjsdfv7/7asdf8/6 sdf 5/5 asdfasdf3/3 asdf 2/2 asdf7/7asfasdf:::::::7/6;;;;;;6/6asdf9/9......alright
sed Command applied on the above input:
sed 's/\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*\(.\/.\).*/\1\t\2\t\3\t\4\t\5\t\6\t\7\t\8\t\9\t\10\t\11/g' infile > outfile
Expected Ouput:
These are some numbers 0/4 8/8 7/7 8/6 5/5 3/3 2/2 7/7 7/6 6/6 9/9 alright
Problem Encountered : but it replaces the last two with 0/40 and 8/81. It is like it can only remember 9 things.
Upvotes: 0
Views: 37
Reputation: 80931
Correct. See The s Command:
The replacement can contain \n (n being a number from 1 to 9, inclusive) references, which refer to the portion of the match which is contained between the nth ( and its matching ). Also, the replacement can contain unescaped & characters which reference the whole matched portion of the pattern space. Finally, as a GNU sed extension, you can include a special sequence made of a backslash and one of the letters L, l, U, u, or E.
Upvotes: 3