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文件,我可以预测信号= 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脚本中获得预测的比特率?
1 个解决方案
#1
1
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.
$ $信号前面的^表示它只在该行的开头匹配。
#1
1
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.
$ $信号前面的^表示它只在该行的开头匹配。