log column in file with awk
Hi
I have a file with 2 columns. What awk command logs the 2nd, forming a new column? Thanx. Gav. |
Quote:
Also: please provide a relevant input and output example (use [code] .. [/code] tags to keep the layout intact). If all you want/need is the second column (assuming space is delimiter): Code:
awk '{ print $2 }' infile |
Quote:
Daniel B. Martin |
Quote:
|
Hi all,thanks for input
the original is like #Sim RMSD 0.00 0.00 1.00 1.61 2.00 1.78 3.00 1.81 4.00 1.89 5.00 1.79 6.00 1.91 7.00 2.20 8.00 2.30 9.00 2.52 10.00 2.50 11.00 2.47 12.00 2.63 13.00 2.77 14.00 2.70 15.00 2.83 16.00 2.72 a 3rd column or new 2nd or new file is great since it is gnuplot input. gav. |
My answer given in post #2 should do the trick. The output must be redirected to a (new) file:
Code:
awk '{ print $2 }' infile > outfile |
that still makes no sense
Code:
awk '{print $0" "$2}' Input Code:
#Sim RMSD RMSD |
Quote:
Well, my solution seems to be option three ;) Quote:
|
Quote:
do nothingSeriously , @gav251 are you certain you don't need to do something to column 2? something like, Code:
awk '{n=$2;print $0" "$2+n}' Input Code:
#Sim RMSD 0 Code:
awk '{n=$2+n;print $0" "$2+n}' Input Code:
#Sim RMSD 0 But the "new 2nd" has me very confused, if the new column 2 is the old column 2 it is still the old column 2 so why do anything? |
Hi all
awk '{ print log $2 }' < rmsd.tab > log.fil why does this give error? thnx. |
Quote:
Code:
awk: { print log $2 } This should work: Code:
awk '{ print $2 }' < rmsd.tab > log.fil PS: You really need to tell us in more detail what it is you are trying to do: - Give us a relevant example of the input used, - Give us the output you expect, - Tell us what didn't work (including the possible error message). We have to assume too many thing as it is and this might lead to unwanted answers. |
Hi.
I'd like to add a bit to previous answers: If you're going to plot resulting file in gnuplot, then you should skip comments in input file, like this for example: Code:
awk '!/^#/{print $2}' rmsd.tab > log.fil And, as Firerat mentioned, you can plot second column of this file directly from gnuplot, e.g.: Code:
plot 'rmsd.tab' u 2 |
Hi, sorry for ambiguity
this prints col 2, I need log value eg 1.0 1.61 0.2068 this is x y logy Gav. |
|
Quote:
Code:
awk '{ print log($2) }' < rmsd.tab > log.fil Code:
awk '{ print $0 " " log($2) }' < rmsd.tab > another |
All times are GMT -5. The time now is 02:16 AM. |