0

So yesterday I used sed command to read the n-th line of multiple files into a single output Read the n-th line of multiple files into a single output and I was able to generate a data.txt file which looks like this:

0 0 0 
-1.08051e-16 -1.73991e-16 -1.79157e-16 
-1.02169e-15 -1.19283e-15 5.92632e-16 
3.41114e-16 -1.02211e-15 3.19436e-15 
......

Note that they are all position data represent x, y and z axis. Now I just want to add one more column using awk command to represent time step which correspond the number of my dump file like 0 250 500...all the way to 40000.

1
  • For what do you need the additional column? If it is for plotting the data with gnuplot, then you can generate this from within the program. But that is only guessed from your tags... not the best way to ask. Commented Jul 27, 2013 at 10:47

1 Answer 1

2

Not sure if I understand your question correctly, but adding a column is pretty trivial in awk. You can do:

$ echo '0 0 0                                       
-1.08051e-16 -1.73991e-16 -1.79157e-16 
-1.02169e-15 -1.19283e-15 5.92632e-16                                             
3.41114e-16 -1.02211e-15 3.19436e-15 ' | awk 'BEGIN{val=0}{print $0,val;val+=250}'
0 0 0 0
-1.08051e-16 -1.73991e-16 -1.79157e-16  250
-1.02169e-15 -1.19283e-15 5.92632e-16  500
3.41114e-16 -1.02211e-15 3.19436e-15  750
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.