I read about sed last week and now, I do some extraction from a file using sed, that is fine,
Now, I would like to change the data in the first column to the line number say
1 3 3 0 0 0 1 3 35 34
16 3 3 0 0 0 34 35 33 19
31 3 3 0 0 0 19 33 71 68
46 3 3 0 0 0 68 71 72 69
61 3 3 0 0 0 69 72 73 70
76 3 3 0 0 0 70 73 67 53
and change the first column to 1 to 6, how can I do this in awk or sed?
Best,
Umut
Definitely
awkfor this scenario. The easiest way I could accomplish this withsedwas in the following form.Where the first expression deletes the first number, and prints the line number
=from the read pipe.The second
sedexpression retrieves two lines at a time and removes the newline\n.This could have not been done through two consecutive expressions because the
=command directly writes the line number to the standard output, which cannot be captured. So I had to recur to anothersedcall.