# Listing strings from file using awr Linux Red Hat

**URL:** <https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281>\
**Category:** Shell Programming and Scripting\
**Created:** [July 3, 2017, 11:17am UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281 "2017-07-03T11:17:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlino70](https://community.unix.com/letter_avatar/carlino70/32/6_449c533f586939b6e5f246632a46421f.png) [@carlino70](https://community.unix.com/u/carlino70)\
**Post date:** [July 3, 2017, 11:17am UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/1 "2017-07-03T11:17:09Z")

</div>

Hi experts, I have a file "salida\_test" containing (in repetitive way):

```nohighlight
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 <

```

I need extract just the lines, in this format:

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

```

and then, filtering again:

```nohighlight
750251 2
140147 2

```

I have a partial filter, but I can�t to obtain the solution:

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

```

shows:

```nohighlight
 Point ID 1.750251
 Point ID 1.140147

```

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

```

shows:

```nohighlight
 value 2
 value 2

```

Could you give me a posible resolution.  
Thanks in advanced  
Regards

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/6_449c533f586939b6e5f246632a46421f.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [July 3, 2017, 11:23am UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/2 "2017-07-03T11:23:02Z")

</div>

Hello carlino70,

Could you please try following and let me know if this helps you.

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

```

Thanks,  
R. Singh

---

<div class="post-metadata">

**Author:** ![carlino70](https://community.unix.com/letter_avatar/carlino70/32/6_449c533f586939b6e5f246632a46421f.png) [@carlino70](https://community.unix.com/u/carlino70)\
**Post date:** [July 3, 2017, 11:31am UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/3 "2017-07-03T11:31:06Z")

</div>

R. Singh, the test doesn�t shows any result:

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

```

Thanks for your help

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/6_449c533f586939b6e5f246632a46421f.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [July 3, 2017, 11:45am UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/4 "2017-07-03T11:45:18Z")

</div>

> [@carlino70](#):
>
> R. Singh, the test doesn�t shows any result:
> 
> ```plaintext
> awk '/Point ID/{sub(/.*\./,"",$3);VAL=$3;next} /^value/{print VAL,$2}' salida_test
> 
> ```
> 
> Thanks for your help

Hello carlino70,

I have the same Input\_file as you posted and after running my code I am getting expected results successfully too as follows.

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

```

Make sure you are NOT having control M characters in your Input\_file, you could check that by `cat -v Input_file` , let me know how it goes then.

Thanks,  
R. Singh

---

<div class="post-metadata">

**Author:** ![carlino70](https://community.unix.com/letter_avatar/carlino70/32/6_449c533f586939b6e5f246632a46421f.png) [@carlino70](https://community.unix.com/u/carlino70)\
**Post date:** [July 3, 2017, 1:08pm UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/5 "2017-07-03T13:08:48Z")

</div>

Thanks R. Singh, it works!

Just I need to delete an space at the first place of each lines (this is because the file "salida\_test" is obtained using an applicattion command and redirecting the output toward him)

Regards!

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_449c533f586939b6e5f246632a46421f.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [July 3, 2017, 6:33pm UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/6 "2017-07-03T18:33:03Z")

</div>

Try also (and watch out for the space!)

```nohighlight
awk '/Point ID|^ value/ {printf "%s%s", $NF, /ID/?FS:RS}' file
1.750251 2
1.140147 2

```

---

<div class="post-metadata">

**Author:** ![carlino70](https://community.unix.com/letter_avatar/carlino70/32/6_449c533f586939b6e5f246632a46421f.png) [@carlino70](https://community.unix.com/u/carlino70)\
**Post date:** [July 4, 2017, 8:22am UTC](https://community.unix.com/t/listing-strings-from-file-using-awr-linux-red-hat/367281/7 "2017-07-04T08:22:32Z")

</div>

Thanks RudiC, your solution also works!.  
Regards!
