Sponsored Content
Top Forums Shell Programming and Scripting parsing config file to create new config files Post 302382959 by radoulov on Sunday 27th of December 2009 02:06:26 PM
Old 12-27-2009
You may try something like this:

Code:
awk -F: '{ map[$1] = $2; idx[NR] = $1 }
NR == 3 {
  n  = split(map[idx[1]], t, c)
  nn = split(map[idx[2]], tt, c)
  for (i=0; ++i<=n;) 
    for (j=0; ++j<=nn;) { 
      print idx[1], t[i] > (fn = t[i] "_" tt[j] ".cfg")
      print idx[2], tt[j] > fn
      print > fn
    }
  next
  }
{ 
  for (i=0; ++i<=n;) 
    for (j=0; ++j<=nn;) 
      print  > (fn = t[i] "_" tt[j] ".cfg") 
  }' OFS=: c=, infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing config file

Hi All, I have a requirement to parse a file. Let me clear you all on the req. I have a job which contains multiple tasks and each task will have multiple attributes that will be in the below format. Each task will have some sequence number according to that sequence number tasks shld... (0 Replies)
Discussion started by: rajeshorpu
0 Replies

2. UNIX for Dummies Questions & Answers

Issue with parsing config variables

I am using MKS tool kit on windows server. One config variable is defined in windows environment and I am trying to use that variable. # Below RootDir is defined in windows RootDir="\\f01\var" # in unix script details="$RootDir/src|$RootDir/tgt" src=`echo $details|awk -F '|' '{print... (1 Reply)
Discussion started by: madhukalyan
1 Replies

3. Shell Programming and Scripting

Need help parsing config file in ksh

Hi all, I've done some searching here but haven't found exactly what I'm looking for so I thought I'd post up and see if someone can help out. I'm working on a shell script that I would like to store environment variables in an external file. I'm familiar with sourcing a file with variables in... (1 Reply)
Discussion started by: kungfusnwbrdr
1 Replies

4. Shell Programming and Scripting

Parsing config-file (perl)

Hi, i'm trying to parse a config file that have alot of rows similar to this one: Example value value value What i want to do is to split and save the row above in a hash, like this: Example = value value value Basically i want to split on the first whitespace after the first... (3 Replies)
Discussion started by: mikemikemike
3 Replies

5. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

6. Shell Programming and Scripting

Parsing Nagios service config files with awk

Hope someone can help, I've been pulling my hair out with this one... I've written a shell script that does a sanity check on our quite extensive Nagios configuration for anything that needs cleaning up but wouldn't make the Nagios daemon necessarily bork or complain. One section of the script... (2 Replies)
Discussion started by: vinbob
2 Replies

7. Shell Programming and Scripting

parsing a config file using bash

Hi , I have a config _file that has 3 columns (Id Name Value ) with many rows . In my bash script i want to be able to parse the file and do a mapping of any Id value so if i have Id of say brand1 then i can use the name (server5X) and Value (CCCC) and so on ... Id Name ... (2 Replies)
Discussion started by: nano2
2 Replies

8. Shell Programming and Scripting

Merge multiple files found in config file

I have a config file with a bunch of these type of blocks: <concat destfile="${standard.js.file}" append="true"> <filelist dir="${js.dir}/foo" files="foo.js, foo2.js"/> <filelist dir="${js.dir}" files="foo3.js"/> <filelist dir="${js.dir}/bar/js"... (11 Replies)
Discussion started by: Validatorian
11 Replies

9. Red Hat

Apache virtual host config vs global config problem

Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY... (1 Reply)
Discussion started by: freebird8z
1 Replies

10. Windows & DOS: Issues & Discussions

(VS 2008) New build config looking files from other folder build config

Hi Team, My new build configuration always looking for the files from the build where i copied from. please help me to resolve this. I am using Visual studio 2008.It has Qt 4.8. plugins,qml,C++ development I created new debug_new build configuration with additional preprocessor from the... (1 Reply)
Discussion started by: SA_Palani
1 Replies
TM::Index(3pm)						User Contributed Perl Documentation					    TM::Index(3pm)

NAME
TM::Index - Topic Maps, generic indexing support SYNOPSIS # this package only provides generic functionality # see TM::Index::* for specific indices DESCRIPTION
One performance bottleneck when using the TM package or any of its subclasses are the low-level query functions "match_forall" and "match_exists". They are looking for assertions of a certain nature. Almost all high-level functions, and certainly TM::TS (TempleScript) use these. This package (actually more its subclasses) provides an indexing mechanism to speed up the "match_*" functions by caching some results in a very specific way. When an index is attached to a map, then it will intercept all queries going to these functions. Open vs. Closed Index There are two options: "open": The default is to keep the index lazy. In this mode the index is empty at the start and it will learn more and more on its own. In this sense, the index lives under an open world assumption (hence the name), as the absence of information does not mean that there is no result. "closed": A closed world index has to be populated to be useful. If a query is launched and the result is stored in the index, then it will be used, like for an open index. If no result in the index is found for a query, the empty result will be assumed. Map Attachment To activate an index, you have to attach it to a map. This is done at constructor time. It is possible (not sure how useful it is) to have one particular index to be attached to several different maps. It is also possible to have several TM::Index::* indices attached to one map. They are then consulted in the sequence of attachments: my $idx1 = new TM::Index::Whatever ($tm); my $idx2 = new TM::Index::Whatever2 ($tm); If $idx1 cannot help, then $idx2 is tried. NOTE: If you use several indices for the same map, then all of them MUST be declared as being open. If one of them were closed, it would give a definite answer and would make the machinery not look further into other indices. This implies that you will have to populate your index explicitly. Hash Technology The default implementation uses an in-memory hash, no further fancy. Optionally, you can provide your own hash object, also one which is tied to an DBM file, etc. INTERFACE
Constructor The only mandatory parameter for the constructor is the map for which this index should apply. The map must be an instance of TM or any of its subclasses, otherwise an exception is the consequence. Optional parameters are "closed" (default: 0) This controls whether the index is operating under closed or open world assumptions. If it is specified to be closed the method "populate" will be triggered at the end of the constructor. "cache" (default: "{}") You optionally can pass in your own HASH reference. Example: my $idx = new TM::Index::Match ($tm) NOTE: When the index object goes out of scope, the destructor will make the index detach itself from the map. Unfortunately, the exact moment when this happens is somehow undefined in Perl, so it is better to do this manually at the end. Example: { my $idx2 = new TM::Index::Match ($tm, closed => 1); .... } # destructor called and index detaches automatically, but only in theory { my $idx2 = new TM::Index::Match ($tm, closed => 1); .... $idx2->detach; # better do things yourself } Methods attach $idx->attach This method attaches the index to the configured map. Normally you will not call this as the attachment is implicitly done at constructor time. The index itself is not destroyed; it is just deactivated to be used together with the map. @@ optional TM detach $idx->detach Makes the index detach safely from the map. The map is not harmed in this process. discard $idx->discard This throws away the index content. is_cached $bool = $idx->is_cached ($key) Given a key parameter, the cache is consulted whether it already has a result for this key. If the index is closed it will return the empty list (reference), if it has no result, otherwise it will give back "undef". do_cache $idx->do_cache ($key, $list_ref) Given a key and a list reference, it will store the list reference there in the cache. SEE ALSO
TM, TM::Index::Characteristics, TM::Index::Match COPYRIGHT AND LICENSE
Copyright 20(0[6]|10) by Robert Barta, <drrho@cpan.org> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-07-18 TM::Index(3pm)
All times are GMT -4. The time now is 03:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy