Sed or awk, update the 1st column of data?

Definitely awk for this scenario. The easiest way I could accomplish this with sed was in the following form cat file | sed "s/^0-9*//g;=;" | sed -n "N;s/\n//g;p Where the first expression deletes the first number, and prints the line number from the read pipe The second sed expression 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 another sed call.

Definitely awk for this scenario. The easiest way I could accomplish this with sed was in the following form. Cat file | sed "s/^0-9*//g;=;" | sed -n "N;s/\n//g;p" Where the first expression deletes the first number, and prints the line number = from the read pipe.

The second sed expression 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 another sed call.

Thanks, this is the trick, continue on reading the manual... – Umut Tabak Aug 23 '10 at 8:36 @Umut: If this answer solved your problem, consider accepting it by clicking the checkbox next to it. (+1 Awk is the right tool for this job. ) – schot Aug 23 '10 at 8:57.

You can try something like this echo "1 3 3 0 0 0 1 3 35 34 " | sed 's/^1 /A /g' Change A to the Number you need and I assume the first column is in the beginning of the line.

Say if I would like to do this in a loop where I loop over the lines and indeed update the first column in this fashion, where it is the beginning of the line. I guess awk is a better option because there are some constructs in the language. I am not sure though... – Umut Tabak Aug 23 '10 at 8:31 and the first column is not always starting with 1.

– ghostdog74 Aug 23 '10 at 8:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions