Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use awk to logarithm a column of data

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report