Sponsored Content
Top Forums Shell Programming and Scripting How to print the extended regular expression ? Post 302552196 by 915086731 on Friday 2nd of September 2011 02:12:22 AM
Old 09-02-2011
Can awk record the match result? FS==" " ,
Code:
2s    4s

so between 2s and 4s exists 4 spaces, the the match results is 4 spaces.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies

2. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

3. Shell Programming and Scripting

Regular expression in grep -E | awk print

Hi All, I have file.txt with contents like this: random text To: recipient@email.co.uk <HTML>S7randomtext more random text random text To: recip@smtpemail.com <HTML>E5randomtext more random text random text I need the output to look like this: 1,,,1,S7 1,,,1,E5 My code so... (9 Replies)
Discussion started by: terry2009
9 Replies

4. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

5. Shell Programming and Scripting

Regular Expression.

can someone let me know what this means in english. \(abcd\) \ is an escape key right? Thanks Also im getting confused with something like it does this mean any single character? and this would be 2 characters ? Just let me know if im on the right track. (5 Replies)
Discussion started by: syco__
5 Replies

6. Shell Programming and Scripting

Would like to print 3 lines after a regular expression is found in the logfile

I would like to print 3 lines after a regular expression is found in the logfile. I'm using the following code: grep -n "$reg_exp" file.txt |while read LINE ;do i=$(echo $LINE |cut -d':' -f1 ) ;sed -n "$i,$(($i+3))p" file.txt ;done The above code things works fine,but sometimes gives erroneous... (3 Replies)
Discussion started by: joachimshaun
3 Replies

7. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

8. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

9. Shell Programming and Scripting

Grep command to search a regular expression in a line an only print the string after the match

Hello, one step in a shell script i am writing, involves Grep command to search a regular expression in a line an only print the string after the match an example line is below /logs/GRAS/LGT/applogs/lgt-2016-08-24/2016-08-24.8.log.zip:2016-08-24 19:12:48,602 ERROR... (9 Replies)
Discussion started by: Ramneekgupta91
9 Replies

10. UNIX for Beginners Questions & Answers

Print byte position of extended ascii character

Hello, I am on AIX. When I encounter extended ascii characters and special characters on a file I need to print.. Byte position, actual character and line number. Is there a simple command that can give me the above result ? Thanks in advance (38 Replies)
Discussion started by: rosebud123
38 Replies
Convert::Color(3pm)					User Contributed Perl Documentation				       Convert::Color(3pm)

NAME
"Convert::Color" - color space conversions and named lookups SYNOPSIS
use Convert::Color; my $color = Convert::Color->new( 'hsv:76,0.43,0.89' ); my ( $red, $green, $blue ) = $color->rgb; # GTK uses 16-bit values my $gtk_col = Gtk2::Gdk::Color->new( $color->as_rgb16->rgb16 ); # HTML uses #rrggbb in hex my $html = '<td bgcolor="#' . $color->as_rgb8->hex . '">'; DESCRIPTION
This module provides conversions between commonly used ways to express colors. It provides conversions between color spaces such as RGB and HSV, and it provides ways to look up colors by a name. This class provides a base for subclasses which represent particular color values in particular spaces. The base class provides methods to represent the color in a few convenient forms, though subclasses may provide more specific details for the space in question. For more detail, read the documentation on these classes; namely: o Convert::Color::RGB - red/green/blue as floats between 0 and 1 o Convert::Color::RGB8 - red/green/blue as 8-bit integers o Convert::Color::RGB16 - red/green/blue as 16-bit integers o Convert::Color::HSV - hue/saturation/value o Convert::Color::HSL - hue/saturation/lightness o Convert::Color::CMY - cyan/magenta/yellow o Convert::Color::CMYK - cyan/magenta/yellow/key (blackness) The following classes are subclasses of one of the above, which provide a way to access predefined colors by names: o Convert::Color::VGA - named lookup for the basic VGA colors o Convert::Color::X11 - named lookup of colors from X11's rgb.txt CONSTRUCTOR
$color = Convert::Color->new( STRING ) Return a new value to represent the color specified by the string. This string should be prefixed by the name of the color space to which it applies. For example rgb:RED,GREEN,BLUE rgb8:RRGGBB rgb16:RRRRGGGGBBBB hsv:HUE,SAT,VAL hsl:HUE,SAT,LUM cmy:CYAN,MAGENTA,YELLOW cmyk:CYAN,MAGENTA,YELLOW,KEY vga:NAME vga:INDEX x11:NAME For more detail, see the constructor of the color space subclass in question. METHODS
( $red, $green, $blue ) = $color->rgb Returns the individual red, green and blue color components of the color value. For RGB values, this is done directly. For values in other spaces, this is done by first converting them to an RGB value using their "to_rgb()" method. COLOR SPACE CONVERSIONS
Cross-conversion between color spaces is provided by the "convert_to()" method, assisted by helper methods in the two color space classes involved. When converting $color from color space SRC to color space DEST, the following operations are attemped, in this order. SRC and DEST refer to the names of the color spaces, e.g. "rgb". 1. If SRC and DEST are equal, return $color as it stands. 2. If the SRC space's class provides a "convert_to_DEST" method, use it. 3. If the DEST space's class provides a "new_from_SRC" constructor, call it and pass $color. 4. If the DEST space's class provides a "new_rgb" constructor, convert $color to red/green/blue components then call it. 5. If none of these operations worked, then throw an exception. These functions may be called in the following ways: $other = $color->convert_to_DEST() $other = Dest::Class->new_from_SRC( $color ) $other = Dest::Class->new_rgb( $color->rgb ) $other = $color->convert_to( $space ) Attempt to convert the color into its representation in the given space. See above for the various ways this may be achieved. If the relevant subclass has already been loaded (either explicitly, or implicitly by either the "new" or "convert_to" methods), then a specific conversion method will be installed in the class. $other = $color->as_$space Methods of this form are currently "AUTOLOAD"ed if they do not yet exist, but this feature should not be relied upon - see below. AUTOLOADED CONVERSION METHODS
This class provides "AUTOLOAD" and "can" behaviour which automatically constructs conversion methods. The following method calls are identical: $color->convert_to('rgb') $color->as_rgb The generated method will be stored in the package, so that future calls will not have the AUTOLOAD overhead. This feature is deprecated and should not be relied upon, due to the delicate nature of "AUTOLOAD". OTHER METHODS
As well as the above, it is likely the subclass will provide accessors to directly obtain the components of its representation in the specific space. For more detail, see the documentation for the specific subclass in question. SUBCLASS METHODS
This base class is intended to be subclassed to provide more color spaces. $class->register_color_space( $space ) A subclass should call this method to register itself as a named color space. $class->register_palette( %args ) A subclass that provides a fixed set of color values should call this method, to set up automatic conversions that look for the closest match within the set. This conversion process is controlled by the %args: enumerate => STRING or CODE A method name or anonymous CODE reference which will be used to generate the list of color values. enumerate_once => STRING or CODE As per "enumerate", but will be called only once and the results cached. This conversion process only finds the closest match in RGB space, so it may not give exact results. In the case of a tie, where two or more colors have the same distance from the target, the first one will be chosen. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.12.3 2011-06-15 Convert::Color(3pm)
All times are GMT -4. The time now is 01:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy