How to use awk to logarithm a column of data
This article mainly introduces the relevant knowledge of "how to use awk to take the logarithm of a column of data". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope this article "how to use awk to take logarithm of a column of data" can help you solve the problem.
Awk has a built-in arithmetic function log (x), which can be used for logarithmic operations on data based on e, while logarithms based on other values can be converted based on this function, for example, logarithms based on 2: log (x) / log (2).
Awk has a built-in arithmetic function log (x), which can be used for logarithmic operations on data based on e, while logarithms based on other values can be converted based on this function, for example, logarithms based on 2: log (x) / log (2).
The following logarithm is taken for the second column of the data (the data is calculated from the second row, and the first row can be output directly or skipped)
[raop@cluster 13:45:13 / share/nas1/raop/project] $cat test.xlsGene FCA 2B 1.5C 0.3D 10
Output Gene\ tlog2 (FC) on the first line of data NR==1 deformation
Logarithm log ($1) / log (2) on the second column of other rows of data
[raop@cluster 13:50:55 / share/nas1/raop/project] $awk'{if (NR==1) print $1 "\ tlog2 (" $2 "); if (NRenestration 1) print $1"\ t "log ($2) / log (2)} 'test.xlsGene log2 (FC) A 1B 0.584963C-1.73697D 3.32193
Awk also involves some other functions:
Cotangent cos (x) cosine function exp (x) in the range of atan2 (x) y) cosine function exp (x) Power int (x) Quadrature log (x) Natural logarithm rand (x) Random number sin (x) Sine sqrt (x) Square Root srand (x) x is the seed of rand () function about "how to use awk to logarithm a column of data", thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.