简体   繁体   English

使用BASH脚本检查txt文件中的预测值

[英]Check the prediction value from txt file using BASH script

I want to check the correlation value from text file using bash script like this : 我想使用bash脚本从文本文件检查相关性值,如下所示:

I have txt file that contains these kind of values : (first column is signal strength and second column is bit rate) 我的txt文件包含以下类型的值:(第一列是信号强度,第二列是比特率)

65 24
67 36
70 48
72 54

Then in bash script I record the current signal like this : 然后在bash脚本中,我像这样记录当前信号:

signal=`iwconfig wlan1 | awk -F'[ =]+' '/Signal level/ {print $7}'`

Let's say the current signal = 67, so based on the txt file, I can predict that signal=67 has bit rate = 36. 假设当前信号= 67,因此基于txt文件,我可以预测到signal = 67的比特率= 36。

How to compare the current signal value with the signal value inside text file hence I can get the predicted bit rate in bash script? 如何将当前信号值与文本文件中的信号值进行比较,从而可以在bash脚本中获得预测的比特率?

One of the easiest things to do would be 最简单的事情之一就是

strength=`grep ^$signal log.txt |cut -d " " -f 2`

but that only matches the exact signal strength. 但这仅与确切的信号强度匹配。

The ^ at the before $signal indicates it only matches at the beginning of the line. $ signal之前的^表示它仅在行的开头匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM