![](/img/trans.png)
[英]Linux Red Hat Bash is directory error , trying to divide one file value from another in Red Hat VI
[英]Listing strings from file using awr Linux Red Hat
我有一個文件“ 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的值以及其第二字段值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.