08-22-2011
Quote:
Originally Posted by
sushimatt
...
What we currently do is cat the log file and pipe it to a perl script that would print to screen all lines with the Session ID, from there we would take each line with Thread-(3 to 8 numbers) and repeat the same entry adding each unrepeated Thread-number to the entry and > to a text file.
...
A much better way to describe this is to provide a short, real-life demonstration using dummy data. Cook up some data in a text file and show us the input to and output from the Perl script. And the changes you want further.
As for the question about passing a qualifier - you could pass a single-character switch to the perl interpreter and then use the "getopts" method of the "GetOpt::Std" module to
(a) parse the switch and (b) perform relevant actions based on the switch.
Link to the CPAN page:
getopts - search.cpan.org
tyler_durden
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Guys,
In the following line:
cn=portal.090710.191533.428571000,cn=groups,dc=mp,dc=rj,dc=gov,dc=br
I need to extract this string: portal.090710.191533.428571000
As you can see this string always will be bettween "cn=" and "," strings.
Someone know one regular expression to... (4 Replies)
Discussion started by: maverick-ski
4 Replies
2. Shell Programming and Scripting
Hi Folks,
In my program, I have a variable which consists of multiple lines. i need to use each line as an input. My intention is to extract the email address of the user in each line and use it to process further.
The email address could be anywhere in the whole line. But there will be only... (5 Replies)
Discussion started by: ragz_82
5 Replies
3. UNIX for Dummies Questions & Answers
Dear all,
Greetings.
I would like to ask for your help to extract lines with specific words in addition 2 lines before and after these lines by using awk or sed.
For example, the input file is:
1 ak1 abc1.0
1 ak2 abc1.0
1 ak3 abc1.0
1 ak4 abc1.0
1 ak5 abc1.1
1 ak6 abc1.1
1 ak7... (7 Replies)
Discussion started by: Amanda Low
7 Replies
4. Shell Programming and Scripting
I have hundreds of files to process. In each file
I need to look for a pattern then
extract value(s) from next line and then
search for value(s) selected from point (2) in the same file at a specific position.
HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V
TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies
5. Shell Programming and Scripting
Hi
Input:
aa-bb-cc-dd.ee.ff.gg
Output:
dd
I want to get the word after the last '-' until the first dot
I have tried with regex lookbehind and lookahead like this:
(?<=-).*(?=\.)
but his returns too much
bb-cc-dd.ee.ff (7 Replies)
Discussion started by: chitech
7 Replies
6. Shell Programming and Scripting
I use "MineOS" (a linux distro with python scripts and web ui included for managing a Minecraft Server). The author of the scripts is currently having a problem with the Minecraft server log file being spammed with certain entries. He's working on clearing up the spam.
But in the meantime, I'm... (8 Replies)
Discussion started by: nbsparks
8 Replies
7. Shell Programming and Scripting
HI,
Just wanted to get some advice on how i can get the next 3 lines after a regex:
Say i have a file which contains something like below:
client467
master tcp ether tor0141 4467
query tcp ether tor0141 4467
client468
master tcp ether tor2141 4468
... (17 Replies)
Discussion started by: reignangel2003
17 Replies
8. Shell Programming and Scripting
Data file example
I look for primary and * to isolate the interesting slot number.
slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'`
Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies
9. Shell Programming and Scripting
In the perl below I am trying to extract and print specic values from patterns using multiple regex. One of the patterns AF= may be a whole number or a decimal but I can not seem
to capture both. I think it is the regex .*AF=(\d+\.\d+); as it is expecting a #.#### and it may only be a #. I tried... (2 Replies)
Discussion started by: cmccabe
2 Replies
10. Shell Programming and Scripting
I have a file conatining the below:
---
10.9.16.116:
/tmp/5835113081224811756.jar:
hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
/tmp/4603745991442278706.jar:
hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
10.9.14.126:
/tmp/conf/extra/httpd-ssl.conf:
hash:... (1 Reply)
Discussion started by: mohtashims
1 Replies
LEARN ABOUT REDHAT
getopt::std
Getopt::Std(3pm) Perl Programmers Reference Guide Getopt::Std(3pm)
NAME
getopt - Process single-character switches with switch clustering
getopts - Process single-character switches with switch clustering
SYNOPSIS
use Getopt::Std;
getopt('oDI'); # -o, -D & -I take arg. Sets $opt_* as a side effect.
getopt('oDI', \%opts); # -o, -D & -I take arg. Values in %opts
getopts('oif:'); # -o & -i are boolean flags, -f takes an argument
# Sets $opt_* as a side effect.
getopts('oif:', \%opts); # options as above. Values in %opts
DESCRIPTION
The getopt() function processes single-character switches with switch clustering. Pass one argument which is a string containing all
switches that take an argument. For each switch found, sets $opt_x (where x is the switch name) to the value of the argument if an argu-
ment is expected, or 1 otherwise. Switches which take an argument don't care whether there is a space between the switch and the argument.
The getopts() function is similar, but you should pass to it the list of all switches to be recognized. If unspecified switches are found
on the command-line, the user will be warned that an unknown option was given.
Note that, if your code is running under the recommended "use strict 'vars'" pragma, you will need to declare these package variables with
"our":
our($opt_x, $opt_y);
For those of you who don't like additional global variables being created, getopt() and getopts() will also accept a hash reference as an
optional second argument. Hash keys will be x (where x is the switch name) with key values the value of the argument or 1 if no argument
is specified.
To allow programs to process arguments that look like switches, but aren't, both functions will stop processing switches when they see the
argument "--". The "--" will be removed from @ARGV.
perl v5.8.0 2002-06-01 Getopt::Std(3pm)