08-19-2009
Perl REGEX - How do extract a string in a line?
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 extract this string?
Any help will be very much appreciated
Best Regards
Pierre
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a variable dynamically generated
$batch = /dataload/R3P/interface/Bowne/reports/RDI00244.rpt
Now I'd like to strip '/dataload/R3P/interface/Bowne/reports/RDI' and '.rpt' from this variable
my output should be only 00244
how to do this using perl regex.I'm a newbie to perl and would... (1 Reply)
Discussion started by: ramky79
1 Replies
2. Shell Programming and Scripting
I'm working on a basic log parser in perl. Input file looks like:
len: 120713
foo
bar
file size of: testdir1/testdir1/testdir1/testdir1/testfile0 is 120713Of course there are tens of thousands of lines... I'm trying to compare the len and filesize values.
#!/usr/bin/perl
use strict;
use... (2 Replies)
Discussion started by: dkozel
2 Replies
3. Shell Programming and Scripting
Hi,
I have a string like
"something is good wanted (bla bla)"
I need to get the world "wanted" from this string and "assign it to a variable".. but it's not a static word so i want to get that word by searching the pattern as follows
<space>desiredword<space>(
and i tried to get that... (6 Replies)
Discussion started by: xlynx3
6 Replies
4. Shell Programming and Scripting
hello mighty all
there's a file with lots of comments.. some of them looks like:
=comment
blabla
blablabla
bla
=cut
i'm trying to cut this out completely with this code:
$line=~s/^=.+?=cut//sg;
but no luck
also tryed to change it abit but still I don't understand how the... (9 Replies)
Discussion started by: tip78
9 Replies
5. Shell Programming and Scripting
Hi,
I've a logfile which i need to parse and get the logs depending upon the user input. here, i'm providing an option to enter the string which can be matched with the log entries.
e.g. one of the logfile entry reads like this -
$str = " mpgw(BLUESOAPFramework):... (6 Replies)
Discussion started by: butterfly20
6 Replies
6. Shell Programming and Scripting
Hello, ksh on Sun5.8 here. I have a pipe-delimited, variable length record file with sub-segments identified with a tilda that we receive from a source outside of our control. The records are huge, and Perl seems to be the only shell that can handle the huge lines. I am new to Perl, and am... (8 Replies)
Discussion started by: gary_w
8 Replies
7. Shell Programming and Scripting
i have a script in which i need to skip comments, and i am able to achieve it partially...
IN text file:
{****************************
{test : test...test }
Script:
while (<$fh>)
{
push ( @data, $_);
}
if ( $data =~ m/(^{\*+$)/ ){
}
With the above match i am... (5 Replies)
Discussion started by: avskrm
5 Replies
8. Shell Programming and Scripting
In the below perl code I am using tags within each line to extract certain information. The tags that are used are:
STB >0.8 is STRAND BIAS otherwise GOOD
FDP is the second number
GO towards the end of the line is read into an array and the value returned is outputed, in the first line that... (1 Reply)
Discussion started by: cmccabe
1 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. UNIX for Beginners Questions & Answers
Hi,
I need some guidance with understanding this Perl script below. I am not the author of the script and the author has not leave any documentation. I supposed it is meant to be 'easy' if you're a Perl or regex guru. I am having problem understanding what regex to use :confused: The script does... (3 Replies)
Discussion started by: newbie_01
3 Replies
LEARN ABOUT OPENSOLARIS
it_tpg_free
it_tpg_create(3ISCSIT) iSCSI Management Library Functions it_tpg_create(3ISCSIT)
NAME
it_tpg_create, it_tpg_delete, it_tpg_free - create and delete iSCSI target portal groups
SYNOPSIS
cc [ flag... ] file... -liscsit [ library... ]
#include <libiscsit.h>
int it_tpg_create(it_config_t *cfg, it_tpg_t **tpg,
char *tpg_name, char *portal_ip_port);
int it_tpg_delete(it_config_t *cfg, it_tpg_t *tpg,
boolean_t force););
void it_tpg_free(it_tpg_t *tpg);
PARAMETERS
cfg a pointer t the iSCSI configuration structure
tpg a pointer to the it_tpg_t structure representing the target portal group
tpg_name an identifier for the target portal group
portal_ip_port a string containing an appropriately formatted IP address:port. Both IPv4 and IPv6 addresses are permitted. This value
becomes the first portal in the target portal group. Applications can add additional values using it_portal_create(3ISC-
SIT) before committing the target portal group. IPv6 addresses should be enclosed in square brackets ('[', ']').
force boolean value indicating if the target portal group should be removed even if it is associated with one or more targets.
If not B_TRUE, the operation will fail if the target product group is associated with a target.
DESCRIPTION
The it_tpg_create() function allocates and creates an it_tpg_t structure representing a new iSCSI target portal group. The new it_tpg_t
structure is added to the global tpg list (cfg_tgt_list) in the it_config_t structure.
The it_tpg_delete() function deletes the target portal group represented by tpg, where tpg is an existing it_tpg_t structure within the
global configuration cfg.
The it_tpg_free() function deallocates resources associated with an it_tpg_t structure. If tpg->next is not NULL, this function frees all
members of the list.
Configuration changes as a result of these functions are not instantiated until the modified configuration is committed by calling it_con-
fig_commit(3ISCSIT).
RETURN VALUES
The it_tpg_create() and it_tpg_delete() functions return 0 on success and an error value on failure.
ERRORS
The it_tpg_create() and it_tpg_delete() functions will fail if:
EBUSY The portal group is associated with one or more targets.
EEXIST The portal was already configured for another portal group associated with this target.
EINVAL A parameter is invalid.
ENOMEM Resources could not be allocated.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
it_config_commit(3ISCSIT), it_ini_create(3ISCSIT), it_portal_create(3ISCSIT), it_tgt_create(3ISCSIT), libiscsit(3LIB), libnvpair(3LIB),
libstmf(3LIB), attributes(5)
SunOS 5.11 1 Oct 2008 it_tpg_create(3ISCSIT)