Top Forums UNIX for Beginners Questions & Answers Filter valid hexadecimal color codes Post 303045967 by sean96 on Monday 20th of April 2020 10:34:46 AM
Old 04-20-2020
So I think I found out a good way of doing it by using grep and regular expression to filter out the non-valid codes but it doesn't seem to work and I don't know why

Code:
grep "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})" colours.txt

 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using color escape codes in less

Hi all, Not sure how "for dummies" this question is, but I'd better use understatement... A. My Environment ============== I am using RedHat Linux, version 2.6.18-53.el5. When I type less --version I get: less 394 Copyright (C) 1984-2005 Mark Nudelman ... My terminal is configured... (1 Reply)
Discussion started by: Source2Exe
1 Replies

2. UNIX for Dummies Questions & Answers

Regular expression on hex color codes

I want to have all hex color codes in a given stylesheet in uppercase, so #fff should be converted to #FFF for instance. Here is the regular expression I use to match and convert hex color codes to uppercase: sed -e 's/^#({3}$)|({6}$)/^#({3}$)|({6}$)/' main.css However, no conversion to uppercase... (6 Replies)
Discussion started by: figaro
6 Replies

3. Programming

Using ANSI color codes in gcc compiled program

I have put some yellow color codes and works well. I call the funstion using print_usage(stderr, 0); I would like to know if there is any way, to store the ansi color codes in variables and then call them inside fprintf. Or have a format followed by the strings I want to output. ... (5 Replies)
Discussion started by: kristinu
5 Replies

4. UNIX for Dummies Questions & Answers

Display file with escaped color codes

Hi, I have a file containing color codes: Fri May 25 17:13:04 2012: Starting MTA: exim4^ Loading cpufreq kernel modules...^How can I display it colorized on a linux terminal? (4 Replies)
Discussion started by: ripat
4 Replies

5. Shell Programming and Scripting

Help with awk color codes based on condition

HI i have two files say test and test1 Test.txt Code: Lun01 2TB 1.99TB 99.6% Lun02 2TB 1.99TB 99.5% Lun03 2TB 1.99TB 99.5% Lun04 2TB 1.55TB 89.6% Code: Test1.txt Lun01 2TB 1.99TB 89.5% Lun02 2TB 1.99TB 99.5% Lun03 2TB 1.99TB 99.5% Requirement is to compare... (6 Replies)
Discussion started by: venkitesh
6 Replies

6. Shell Programming and Scripting

Filter Data based on codes

Hello, I have a question on how to filter the data on multiple columns. The problem is I have one table with 25 columns, 4500 rows. I need to filter out the data based on some codes like 'XXXX', I have 25 codes to check on that table. My requirement is that which ever row has this code I... (1 Reply)
Discussion started by: sandeep309
1 Replies
XParseColor()															     XParseColor()

Name
  XParseColor - look up RGB values from ASCII color name or translate hexadecimal value.

Synopsis
  Status XParseColor(display, colormap, spec, exact_def_return)
	Display *display;
	Colormap colormap;
	char *spec;
	XColor *exact_def_return;

Arguments
  display   Specifies a connection to an X server; returned from XOpenDisplay().

  colormap  Specifies a colormap associated with the screen on which to look up the color.  This argument is required, but is meaningful only
	    with Xcms color specifications.

  spec	    Specifies the color string (see the "Description" section).  Uppercase or lowercase does not matter.  If the color name is not in
	    the Host Portable Character Encoding, the result is implementation-dependent.

  exact_def_return
	    Returns  the  RGB values corresponding to the specified color name or hexadecimal specification, and sets its DoRed, DoGreen, and
	    DoBlue flags.

Returns
  Zero on failure, non-zero on success.

Description
  XParseColor() looks up the string name of a color with respect to the screen associated with the specified colormap.	It returns the	exact
  color value.	It or hexadecimal values specified, or translating the hexadecimal code into separate RGB values.

  XParseColor() takes a string specification of a color, typically from a user-specified command line or resource value, and returns the cor-
  responding red, green, and blue values, suitable for a subsequent call to XAllocColor or XStoreColor().   spec  can  be  given  in  several
  forms, and may be looked up in different ways depending on the form.

  o  Color name, such as "blue".  This form is looked up in the server's RGB database, a sample of which is listed in Appendix D, The Server-
     side Color Database.

  o  Xcms color name, such as TekHVC:0.0/100.0/0.0.  This form is looked up in the client-side database for the screen	associated  with  the
     specified	colormap.   This  form is supported starting in Release 5.  For more information on this form of color specification, see the
     Programmer's Supplement for Release 5, or the Third Edition of Volume One.

  o  Hexadecimal specification such as #3a7.  This form consists of an initial sharp sign character followed by one of the following formats:

	#RGB   (one character per color)
	#RRGGBB   (two characters per color)
	#RRRGGGBBB   (three characters per color)
	#RRRRGGGGBBBB	(four characters per color)

     where R, G, and B represent single hexadecimal digits (uppercase or lowercase).  The hexadecimal strings must be NULL-terminated so that
     XParseColor()  knows  when it has reached the end.  When fewer than 16 bits each are specified, they represent the most significant bits
     of the value.  For example, #3a7 is the same as #3000a0007000.  The hexadecimal style is discouraged in Release 5 and later.

  Status is zero on failure, non-zero on success.  This routine will fail if the initial character is a sharp sign but the  string  otherwise
  fails  to  fit one of the above formats, or if the initial character is not a sharp sign and the named color does not exist in the server's
  database.

  For more information, see Volume One, Chapter 7, Color and in the Third Edition, the chapter on Device-Independent Color.

Structures
     typedef struct {
	 unsigned long pixel;
	 unsigned short red, green, blue;
	 char flags;	/* DoRed, DoGreen, DoBlue */
	 char pad;
     } XColor;

Errors
  BadColor  Invalid colormap.

See Also
  XBlackPixel(), XWhitePixel(), XAllocColor(), XcmsAllocColor(), XAllocColorCells(), XAllocColorPlanes(), XAllocNamedColor(), XcmsAllocNamed-
  Color(),  XFreeColors(), XLookupColor(), XQueryColor(), XQueryColors(), XStoreColor(), XcmsStoreColor(), XStoreColors(), XcmsStoreColors(),
  XStoreNamedColor().

Xlib - Color Cells														     XParseColor()

Featured Tech Videos

All times are GMT -4. The time now is 08:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy