linux - 使用 awr Linux Red Hat 从文件中列出字符串

标签 linux shell scripting awr

我有一个文件“salida_test”包含(以重复的方式):

Point ID   1.750251
 Point Name >BRI_4L_SA2__INT Interruptor 33kV Parque Industrial              <
 value 2
 Time of last value update   (ascii): >03/07/17 11:11:14.596 ART<
 TLQ   0000000c00004000
 station #79    abbr: >BRI         <  full: >E.T. BRIGADIER LOPEZ            <

 Point ID   1.140147
 Point Name >RUF_5BC1____INT Int. Banco Cap. 1 13.2kV                        <
 value 2
 Time of last value update   (ascii): >03/07/17 10:27:58.495 ART<
 TLQ   0000000c00800000
 station #18    abbr: >RUF         <  full: >E.T. RUFINO   

              <

我只需要以这种格式提取行:

Point ID   1.750251  value 2    --> in the same line
Point ID   1.140147  value 2    --> in the same line

然后,再次过滤:

750251 2
140147 2

我有一个部分过滤器,但我无法获得解决方案:

awk '(/Point ID/ || /hi/)' salida_test

显示:

 Point ID   1.750251
 Point ID   1.140147

和:

awk '(/value/ || /hi/) && !/Time of last value/' salida_test

显示:

value 2
value 2

你能给我一个可行的解决方案吗?

最佳答案

尝试:

awk '/Point ID/{sub(/.*\./,"",$3);VAL=$3;next} /^value/{print VAL,$2}'  Input_file

说明: 查找其中包含字符串“point ID”的行,然后将其第 3 个字段替换为 DOT 并将其保存到名为 VAL 的变量中,然后使用next 将跳过 awk 的所有进一步语句。现在 ^Value 将检查从它开始的行/记录,如果是,那么它将简单地打印变量 VAL 的值以及它的第二个字段值。

关于linux - 使用 awr Linux Red Hat 从文件中列出字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44889272/

相关文章:

linux - 在 Linux 上创建文件的命令是什么?

linux - 最短线的长度?

c# - Unity(对象名称与游戏对象)

html - 如何将 Linux 的 shell 输出转换为 HTML?

powershell - 是否可以使 cmdlet 与同时通过管道传输到其中的所有项目一起工作?

c++ - 在网络上传输数据

linux - 在aarch64 Linux中安装anaconda

linux - 将 openssl 0.9.8g 升级到 1.0.1e

linux - 复制文件,不包括 linux 中的某些文件夹

bash - 如何不敏感地检查文件相似度大小写