01-27-2009
Extra/parse lines from a file between unque lines through the file
I need help to parse a file where there are many records, all of which are consistently separated by lines containing “^=============” and "^ End of Report".
Example:
=============
1
2
3
4
End of record
=============
1
3
4
End of record
Etc....
I only need specific lines within start and finish.
Output
1,2,3
1,3
Etc...
As a bonus it would also help if I could extract allines start content and finish to a file as in
fileA
==============
1
2
3
4
End of record
fileB
==============
1
3
4
End of record
Etc...
I have had the need for this several times and never had much luck processing it myself.
Any suggestions will be greatly appreciated.
I have looked this up and just didn't find one with an example that fit my circumstances.
I prefer to use ksh
Any suggestions will be greatly appreciated.
#
#
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have some files, with some extra lines in weird characters on the top and bottom of the. I want to get rid of those line. Is there a way I can do that?
example of the input file. I want to get rid of those lines in bold
(B
... (8 Replies)
Discussion started by: CamTu
8 Replies
2. Shell Programming and Scripting
I have files that store multiple data points for the same device "vertically" and include multiple devices. It repeats a consistant pattern of lines where for each line:
Column 1 is a common number for the entire file and all devices in that file
Column 2 is a unique device number
Column 3 is... (7 Replies)
Discussion started by: STN
7 Replies
3. Shell Programming and Scripting
Hi!
I'm trying to create a shell script to parse a file which might have multiple lines matching a pattern (i.e. containing some word).
I need to return all lines matching the pattern, but stripping the contents of that line until the pattern is matched
For example, if my input file was
... (4 Replies)
Discussion started by: orno
4 Replies
4. Shell Programming and Scripting
For example, I have a file with below lines containing VOB tags and VOB paths.
* /vobs/fts/FTSUSM20_VOB /ccvobsslx01/projects/vobs/eml/FTSUSM20_VOB
* /vobs/fts/FTS20_VOB /ccvobsslx01/projects/vobs/eml/FTS20_VOB
* /vobs/pmv/PMS_VOB /ccvobsslx01/projects/vobs/cpm/_/PMS_VOB
*... (4 Replies)
Discussion started by: senthilkc
4 Replies
5. Shell Programming and Scripting
I have a file that needs to be parsed into multiple files every time there line contains a number 1. the problem i face is the lines are random and the file size is random. an example is that on line 4, 65, 187, 202 & 209 are number 1's so there has to be file breaks between all those to create 4... (6 Replies)
Discussion started by: darbs121
6 Replies
6. Shell Programming and Scripting
hi,
i have two files.
file1.sh
echo "unix"
echo "linux"
file2.sh
echo "unix linux forums"
now the output i need is
$./file2.sh
unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies
7. Shell Programming and Scripting
I was looking at this script which outputs the two lines which differs less than one sec.
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
use constant SEC_MILIC => 1000;
my $file='infile';
## Open for reading argument file.
open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies
8. Shell Programming and Scripting
Consolidate several lines of a CSV file with firewall rules
Hi guys.
I have a CSV file, which I created using an HTML export from a Check Point firewall policy.
Each rule is represented as several lines, in some cases. That occurs when a rule has several address sources, destinations or... (4 Replies)
Discussion started by: starriol
4 Replies
9. Shell Programming and Scripting
I have a file where data looks like this:
===
<?xml version="1.0" encoding="utf-8"?>
<xml xmlns:s='uuid:XYZ'
xmlns:dt='uuid:ABC'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row'... (7 Replies)
Discussion started by: vx04
7 Replies
10. Shell Programming and Scripting
I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies
LEARN ABOUT DEBIAN
log::log4perl::config::baseconfigurator
Config::BaseConfigurator(3pm) User Contributed Perl Documentation Config::BaseConfigurator(3pm)
NAME
Log::Log4perl::Config::BaseConfigurator - Configurator Base Class
SYNOPSIS
This is a virtual base class, all configurators should be derived from it.
DESCRIPTION
METHODS
"new"
Constructor, typically called like
my $config_parser = SomeConfigParser->new(
file => $file,
);
my $data = $config_parser->parse();
Instead of "file", the derived class "SomeConfigParser" may define any type of configuration input medium (e.g. "url =>
'http://foobar'"). It just has to make sure its "parse()" method will later pull the input data from the medium specified.
The base class accepts a filename or a reference to an array of text lines:
"file"
Specifies a file which the "parse()" method later parses.
"text"
Specifies a reference to an array of scalars, representing configuration records (typically lines of a file). Also accepts a simple
scalar, which it splits at its newlines and transforms it into an array:
my $config_parser = MyYAMLParser->new(
text => ['foo: bar',
'baz: bam',
],
);
my $data = $config_parser->parse();
If either "file" or "text" parameters have been specified in the constructor call, a later call to the configurator's "text()" method
will return a reference to an array of configuration text lines. This will typically be used by the "parse()" method to process the
input.
"parse"
Virtual method, needs to be defined by the derived class.
Parser requirements
o If the parser provides variable substitution functionality, it has to implement it.
o The parser's "parse()" method returns a reference to a hash of hashes (HoH). The top-most hash contains the top-level keywords
("category", "appender") as keys, associated with values which are references to more deeply nested hashes.
o The "log4perl." prefix (e.g. as used in the PropertyConfigurator class) is stripped, it's not part in the HoH structure.
o Each Log4perl config value is indicated by the "value" key, as in
$data->{category}->{Bar}->{Twix}->{value} = "WARN, Logfile"
EXAMPLES
The following Log::Log4perl configuration:
log4perl.category.Bar.Twix = WARN, Screen
log4perl.appender.Screen = Log::Log4perl::Appender::File
log4perl.appender.Screen.filename = test.log
log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
needs to be transformed by the parser's "parse()" method into this data structure:
{ appender => {
Screen => {
layout => {
value => "Log::Log4perl::Layout::SimpleLayout" },
value => "Log::Log4perl::Appender::Screen",
},
},
category => {
Bar => {
Twix => {
value => "WARN, Screen" }
} }
}
For a full-fledged example, check out the sample YAML parser implementation in "eg/yamlparser". It uses a simple YAML syntax to specify the
Log4perl configuration to illustrate the concept.
SEE ALSO
Log::Log4perl::Config::PropertyConfigurator
Log::Log4perl::Config::DOMConfigurator
Log::Log4perl::Config::LDAPConfigurator (tbd!)
COPYRIGHT AND LICENSE
Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.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-21 Config::BaseConfigurator(3pm)