![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| converting date format | mohan705 | Shell Programming and Scripting | 7 | 05-22-2008 11:10 AM |
| converting text to csv format | gthokala | Shell Programming and Scripting | 13 | 06-09-2006 10:44 AM |
| converting PDF to text, rtf doc format | saurya_s | UNIX for Advanced & Expert Users | 1 | 04-23-2004 03:25 PM |
| Converting BMP to BM (or other unix format) | EJ =) | UNIX Desktop for Dummies Questions & Answers | 1 | 06-12-2002 08:42 AM |
| Converting the File Creation Date to a new format | barney_clough | UNIX for Dummies Questions & Answers | 1 | 06-12-2002 07:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
converting config file to csv format
Hello,
For 2 days now i've been searching for a solution to this. I am now beginning to doubt this is even possible. It's even harder when you don't know how to search for it. (which keywords generate enough relevancy etc..) I need to parse a config file to generate a CSV file in return. It would need to take these parameters out of the file: define host{ host_name hostA parents hostNull } -- define host{ host_name hostB parents hostA } -- define host{ host_name hostC parents hostB } -- and create this: host,parent hostA,hostNull hostB,hostA hostC,hostB Does anyone know a solution to this or can someone point me out to some doc that explains how ? |
|
||||
|
A Perl One-Liner
Code:
$ cat temp.txt | perl -ne 'chomp; print "host,parent\n" if $. == 1; print $_ if $_ =~ s/^host_name\s+(.*)$/$1/; print ",$_\n" if $_ =~ s/^parents\s+(.*)$/$1/;' host,parent hostA,hostNull hostB,hostA hostC,hostB 2. Print the host name if found (with no newline) 3. Print the comma, parent name, and newline when parent is found. ShawnMilo |
|
||||
|
Thank you very much for all your replies, i will give them a try today and let you know how it turned out.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|