首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在使用“cat”和“ls”这样的词时,是否有获得行索引的方法?

在使用“cat”和“ls”这样的词时,是否有获得行索引的方法?
EN

Stack Overflow用户
提问于 2018-01-25 06:06:19
回答 1查看 230关注 0票数 1

我正在寻找获得特别是“猫”的线路号码的方法。

我在ubuntu 16.04上尝试了这样的命令

代码语言:javascript
复制
cat flux.log |grep "statistic"

这就是发现信息的结果。

代码语言:javascript
复制
 Using fit statistic: chi
 Using test statistic: chi
Fit statistic : Chi-Squared =         175.92 using 16 PHA bins.
Test statistic : Chi-Squared =         175.92 using 16 PHA bins.
Fit statistic : Chi-Squared =         175.92 using 16 PHA bins.
Test statistic : Chi-Squared =         175.92 using 16 PHA bins.
 Fit statistic in use: Chi-Squared
 Using fit statistic: chi
 Using test statistic: chi
Fit statistic : Chi-Squared =         175.92 using 16 PHA bins.
Test statistic : Chi-Squared =         175.92 using 16 PHA bins.
Fit statistic : Chi-Squared =           6.05 using 16 PHA bins.
Test statistic : Chi-Squared =           6.05 using 16 PHA bins.
Fit statistic : Chi-Squared =           6.05 using 16 PHA bins.
Test statistic : Chi-Squared =           6.05 using 16 PHA bins.
Fit statistic : Chi-Squared =           6.05 using 16 PHA bins.
Test statistic : Chi-Squared =           6.05 using 16 PHA bins.
Fit statistic : Chi-Squared =           6.05 using 16 PHA bins.
Test statistic : Chi-Squared =           6.05 using 16 PHA bins.
Fit statistic : Chi-Squared =           6.05 using 16 PHA bins.
Test statistic : Chi-Squared =           6.05 using 16 PHA bins.
Fit statistic : Chi-Squared =          66.15 using 16 PHA bins.
Test statistic : Chi-Squared =          66.15 using 16 PHA bins.
 Fit statistic in use: Chi-Squared
 Using fit statistic: chi
 Using test statistic: chi
Fit statistic : Chi-Squared =          66.15 using 16 PHA bins.
Test statistic : Chi-Squared =          66.15 using 16 PHA bins.

在这个结果中,我想用最后一行来捕捉信息。

代码语言:javascript
复制
Fit statistic : Chi-Squared =          66.15 using 16 PHA bins.
Test statistic : Chi-Squared =          66.15 using 16 PHA bins.

问题是有很多行,而这些数字是随机的。所以我只有“适合”、“测试”、“统计”或“X-平方”这样的信息来查找。

如果这些结果有行号,并且可以被区分,我可以找到我想要的行。有人帮我吗?

ps,我试过这个命令

代码语言:javascript
复制
<cat -n flux.log |grep "statistic">

但是每个文件的所有行都是不同的。

EN

回答 1

Stack Overflow用户

发布于 2018-01-25 06:55:54

试试man nl。也是awk '{print NR,$0}' myfile

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48436615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档