Sponsored Content
Top Forums Shell Programming and Scripting Perl REGEX - How do extract a string in a line? Post 302345967 by durden_tyler on Thursday 20th of August 2009 05:54:29 PM
Old 08-20-2009
Quote:
Originally Posted by maverick-ski
...
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
...
Someone know one regular expression to extract this string?
...
Try non-greedy regex match:

Code:
$ 
$ echo "cn=portal.090710.191533.428571000,cn=groups,dc=mp,dc=rj,dc=gov,dc=br" | perl -lne '/^cn=(.*?),/ && print $1'
portal.090710.191533.428571000
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how do i strip this line using perl regex.

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

Perl Regex string opperation

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

Perl Extract String

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

perl regex multi line cut

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

Perl: Regex, string matching

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

Perl regex to remove a segment in a line

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

perl regex string match issue..kindly help

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

Perl to extract information from a file line by line

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

Perl to extract whole number or decimal in regex

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

Help with understanding this regex in a Perl script parsing a 'complex' string

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
istgtcontrol(1) 					      General Commands Manual						   istgtcontrol(1)

NAME
istgtcontrol - istgt iSCSI target command utility SYNOPSIS
istgtcontrol [options] <command> [<file>] DESCRIPTION
istgtcontrol is a command and control utility for istgt(1). It can be used to query and change the status of a local or remote istgt instance. istgtcontrol supports the commands denoted below to interact with the istgt instance. By default it connects and authenticates to the iSCSI target portal specified in the istgtcontrol.conf configuration file and uses CHAP credentials denoted there, if any. Both can be overrid- den by using the respecitve command line arguments. COMMANDS
istgtcontrol understands the following commands which can be forwarded to istgt: noop Do not actually do anything, but test responsiveness of the portal and test CHAP credentials only. version Retrieve the istgt version number providing the iSCSI portal istgtcontrol connected to. list List all, or the specified targets only, which shared by the portal. load Load a new media to the specified unit. This command issues the same command as if a drive tray had been closed on a SCSI device. unload Unload a media from the specified unit. This command issues the same command as if the drive tray had been opened from a SCSI device. change file Change the loaded media by the specified unit. This command is equivalent as if a new media (for example a DVD-ROM or tape car- tridge) had been inserted in the SCSI drive. The "file" argument is interpreted as filename to be loaded. reset Reset the specified LUN of the portal. info Display all connections of the portal OPTIONS
-c config Use specified file as configuration file instead of the default file. -h host Override the target portal by the specified host name or IP address. This defaults to "localhost" if no other host was specified in the configuration file. -p port Override the target portal port by the specified port number. This defaults to "3261" if no other port was specified in the configu- ration file. -t target Specifies the target IQN which should be affected by the command given. There may be a default given in the configuration file. The keyword "all" is accepted by some commands and matches all exported volumes. -l lun Specifies the target LUN which should be affected by the command given. This defaults to "0" unless another default was provided in the configuration file. -f flags Specifies flags passed to the portal when loading a new media. This defaults to "ro". Supported flags are: "ro", "rw", "extend" and "dynamic". -s size Specifies the size of the meda to be loaded. The default is to auto-detect the media size. -q Quiet mode, supress non-critical outputs. -v Verbose mode, gives more output during operations. -A method Sets the preferred authentication method for logging in to the portal. This overrides any method specified in the configuration file. Supported methods are either CHAP/Mutual or CHAP/Auto. -U user Sets the user to authenticate on the portal. This overrides any username specified in the configuration file. -S secret Set the secret used to authenticate on the portal. This overrides any secret specified in the configuration file. -M muser Set the mutual authentication user. This overrides any user specified in the configuration file. -R msecret Set the mutual authentication secret. This overrides any secret specified in the configuration file. -H Display a brief usage summary and exit. -V Display the istgtcontrol version number and exit. FILES /etc/istgt/istgtcontrol.conf Configuration file SEE ALSO
istgt(1) AUTHORS
Daisuke Aoyama <aoyama@peach.ne.jp> This manual page was written by Arno Toll (<debian@toell.net>) for the Debian GNU/kFreeBSD system (but may be used by others). istgtcontrol Oct 07, 2011 istgtcontrol(1)
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy