Listing strings from file using awr Linux Red Hat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listing strings from file using awr Linux Red Hat
# 1  
Old 07-03-2017
Wrench Listing strings from file using awr Linux Red Hat

Hi experts, I have a file "salida_test" containing (in repetitive way):

Code:
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:

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

and then, filtering again:

Code:
750251 2
140147 2

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

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

shows:

Code:
 Point ID   1.750251
 Point ID   1.140147

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

shows:
Code:
 value 2
 value 2

Could you give me a posible resolution.
Thanks in advanced
Regards
# 2  
Old 07-03-2017
Hello carlino70,

Could you please try following and let me know if this helps you.
Code:
awk '/Point ID/{sub(/.*\./,"",$3);VAL=$3;next} /^value/{print VAL,$2}'   Input_file

Thanks,
R. Singh
# 3  
Old 07-03-2017
R. Singh, the test doesnīt shows any result:

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

Thanks for your help
# 4  
Old 07-03-2017
Quote:
Originally Posted by carlino70
R. Singh, the test doesnīt shows any result:
Code:
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.
Code:
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
# 5  
Old 07-03-2017
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!
# 6  
Old 07-03-2017
Try also (and watch out for the space!)
Code:
awk '/Point ID|^ value/ {printf "%s%s", $NF, /ID/?FS:RS}' file
1.750251 2
1.140147 2

# 7  
Old 07-04-2017
Thanks RudiC, your solution also works!.
Regards!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Converting fixed width file to pipe delimiter in Linux(red-hat)

Hi, I am facing a typical scenario for AWK command . In HP- UNIX is behave as expected but in red hat linux same awk code is not give the same result. The below code is for convert the fixed width file to pipe delimiter file in HP-unix server. awk code: #!/bin/awk -f NR!=1... (11 Replies)
Discussion started by: brij_abhi
11 Replies

2. Fedora

Which is the better platform to learn UNIX/Linux (Kali Linux Vs. Red Hat or other)?

I just started a new semester and I started my UNIX class yesterday. I've already decided to use python along with my learning process but what I really want to use with it is Kali as my UNIX/Linux platform to learn off of since I already wanted to learn Cyber Sec. anyways. I just wanted to know if... (12 Replies)
Discussion started by: ApacheOmega
12 Replies

3. Shell Programming and Scripting

Directory / File changes on CIFS share mounted on Red Hat Linux

I have a requirement to copy the changed file on CIFS share mounted on Red Hat Linux to a remote FTP/SFTP server. I tried inotify-tools, but this didn't track the modified files. Has anyone tried incron or any other suggestion? (1 Reply)
Discussion started by: SupeAlok
1 Replies

4. UNIX for Dummies Questions & Answers

how to know if i use "Red Hat Enterprise Linux" or "Red Hat Desktop" ?

how to know if i use "Red Hat Enterprise Linux" or "Red Hat Desktop" ? (2 Replies)
Discussion started by: ahmedamer12
2 Replies

5. Homework & Coursework Questions

File transfer from Red Hat Linux to Windows 7

My assignment is to use C++ to generate a table of values for the U.S. standard atmosphere, when data at sea level are given, which i have done perfectly. Now, i am attempting to create a matlab script to read and plot the data. I forgot to put my table of data on my thumb drive yesterday, and... (4 Replies)
Discussion started by: ds7202
4 Replies

6. Red Hat

Red Hat Linux document

Hi Friends, I am working in new platform I need the document for Red hat Linux. Anybody have pls share with me. Regards, Thangadurai M (2 Replies)
Discussion started by: thangadurai
2 Replies

7. Linux

Red Hat Linux 9

Hello there! Will anybody please tell me some good links to online eBooks on Red Hat Linux 9 user experiences and the like. If the books are in PDF Format, it will be nice to read. Thanks for cooperation in advance. Enjoy using open source and breathe freely! JAM (5 Replies)
Discussion started by: Jawwad
5 Replies

8. UNIX for Dummies Questions & Answers

XP to Linux (Red Hat)

I have a PC running XP, and I have a PC that dual boots W2K and Red Hat Linux 7.3. I have the two connected via crossover cable, and the two can access each other when both are running windows. If I were to boot up Linux, can my XP PC telnet to the Linux PC? Any pointers or websites to... (3 Replies)
Discussion started by: lawadm1
3 Replies

9. UNIX for Dummies Questions & Answers

Slackware's Linux 3.0 VS Red Hat Linux 7.x

Hello guys, I got overzealous (I Think). I got the book Linux Unleashed that comes with the Slackware 3.0 Version of Linux for $2.00.I also have Red Hat Linux 7.2 (No book, just the OS).What I wanted to know was,other than the bells and whistles of Red Hat is there any significant difference... (2 Replies)
Discussion started by: perrylx
2 Replies

10. UNIX for Dummies Questions & Answers

Red Hat Linux 6.0

Ok here is my problem i do not know the command to load a driver for my network card in Ted hat linux 6.0 could sombody give me a hand. and if there is anyone that has a list of commands for red hat that would be great also (2 Replies)
Discussion started by: bbutler3295
2 Replies
Login or Register to Ask a Question