Simplified file conversion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simplified file conversion
# 1  
Old 05-15-2018
Simplified file conversion

Hi All,

I have a file like below
Code:
Topic:price   PartitionCount:5       ReplicationFactor:3     Configs:
        Topic: price  Partition: 0    Leader: 13      Replicas: 13,15,11      Isr: 11,13
        Topic: price  Partition: 1    Leader: 14      Replicas: 14,11,12      Isr: 11,12,14
        Topic: price  Partition: 2    Leader: 12      Replicas: 15,12,13      Isr: 12,13
        Topic: price  Partition: 3    Leader: 11      Replicas: 11,13,14      Isr: 11,14,13
        Topic: price  Partition: 4    Leader: 12      Replicas: 12,14,15      Isr: 12,14

I would like to convert this file into below
Code:
Topic, Partition, Replica Count, ISR Count(In-sync Replica Count)

ln-short the o/p file should look like below
Code:
Price, 0, 3, 2
price, 1, 3, 3
price, 2, 3, 2
price, 3, 3, 3
price, 4, 3, 2

Can anyone help me out?
# 2  
Old 05-15-2018
Code:
awk 'NR > 1 {print $3, $5, gsub(",", _, $9)+1, gsub(",", _, $11)+1}' FS="[ :\t]+" OFS=", " infile


Last edited by rdrtx1; 05-15-2018 at 11:54 AM.. Reason: Added tab to field separator.
# 3  
Old 05-15-2018
thanks but i don't think it's printing in right order.
it's printing like this

Code:
0       Leader, 13,15,11        Isr, 1, 1
1       Leader, 14,11,12        Isr, 1, 1
2       Leader, 15,12,13        Isr, 1, 1
3       Leader, 11,13,14        Isr, 1, 1
4       Leader, 12,14,15        Isr, 1, 1

# 4  
Old 05-15-2018
See update.
This User Gave Thanks to rdrtx1 For This Post:
# 5  
Old 05-15-2018
Quote:
Originally Posted by rdrtx1
See update.
me bad....sorry.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simplified Code? Acceptable?

Hi Folks - I have the following peice of code that I believe is uncecesarily long and I modified it to shorten it up. I was hoping one could comment and confirm my approach was acceptable? Original: if then pushd "${_INTRAPATH}" #Search for lines in... (1 Reply)
Discussion started by: SIMMS7400
1 Replies

2. What is on Your Mind?

Simplified Registration Page with nCaptcha

At Ravinder's request, I have simplified the new member registration page on both mobile and desktop: Mobile: https://www.unix.com/members/1-albums214-picture909.jpeg Desktop (big image): https://www.unix.com/members/1-albums215-picture907.png (2 Replies)
Discussion started by: Neo
2 Replies

3. What is on Your Mind?

New Simplified Log Out for UNIX.COM

Hi, I changed the logout code to just simply log out and go back to the page you were viewing: Was (ending code): eval(standard_error(fetch_error('cookieclear', create_full_url($vbulletin->url), $vbulletin->options, $vbulletin->session->vars), '', false)); Now: $goto = "Location:... (0 Replies)
Discussion started by: Neo
0 Replies

4. Shell Programming and Scripting

Simplified awk script for if else statements

Hi, The below awk script that i did is working fine. It gives me the results that i want. But, the script is not smart and very long as i have 8 conditions to meet. The sample script below only show 2 conditions. awk 'BEGIN{FS=OFS=" ~ |\t"} {if (($7>$9) && ($6>$8)){ Ql= $7-$6; Sl=... (6 Replies)
Discussion started by: redse171
6 Replies

5. Linux

File conversion and removing special characters from a file in Linux

I have a .CSV file when I check for the special characters in the file using the command cat -vet filename.csv, i get very lengthy lines with "^@", "^I^@" and "^@^M" characters in between each alphabet in all of the records. Using the code below file filename.csv I get the output as I have a... (2 Replies)
Discussion started by: dhruuv369
2 Replies

6. Shell Programming and Scripting

Conversion of spaces Text file into CSV format file

Input file (each line is separaed by spaces )given below: Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- -----... (18 Replies)
Discussion started by: sreenath1037
18 Replies

7. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

8. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

9. Linux

Simplified find command to find multiple file types

Hi, I'm using the following command to find the multiple requierd file types and its working fine find . -name "*.pl" -o -name "*.pm" -o -name "*.sql" -o -name "*.so" -o -name "*.sh" -o -name "*.java" -o -name "*.class" -o -name "*.jar" -o -name "*.gz" -o -name "*.Z" -type f Though... (2 Replies)
Discussion started by: vickramshetty
2 Replies

10. Solaris

COnversion utility xhtml file to Postscript file

Hi, Can any suggest me some utility to convert xhtml file to postscript file format? Also tell me from where to down load such utility.. With Regards, Dattatray (0 Replies)
Discussion started by: dattatray.b
0 Replies
Login or Register to Ask a Question