Sponsored Content
Top Forums Shell Programming and Scripting Need a quick and dirty solution Post 302664047 by alister on Thursday 28th of June 2012 07:04:14 PM
Old 06-28-2012
Quote:
Originally Posted by Corona688
Code:
$ awk '(!A[$1]) || (A[$1] < $2) { A[$1]=$2 }; END { for (X in A) { print X, A[X] } }' <<EOF

Given that the sample version data contains components of varying widths, e.g. 2.2 and 2.21, I don't think this code is sufficient.

The highlighted expression is a string comparison. v3.9 will be considered greater than v3.10. If the comparison were made using numeric substrings, 3.9 would still be greater than 3.10.

Regards,
Alister

---------- Post updated at 07:04 PM ---------- Previous update was at 07:00 PM ----------

Quick and dirty, as per the topic:
Code:
tr . '\t' < file | sort -k1,1 -k2.2b,2nr -k3,3nr | awk 'p!=$1 {p=$1; print}' | tr '\t' .

Assumes there is only the one dot in the version numbers, that there are no tabs in the file, and that your field delimiter is a space. If the delimiter is a tab and there are no spaces, change \t to a space.

Regards,
Alister

Last edited by alister; 06-28-2012 at 08:15 PM..
 

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Quick-and-dirty g++ compilation

I am creating a small bash file that will take one argument and compile it: #!/bin/bash OUT=${$1%.cpp} # C++ source files always end in .cpp g++ -Wall $1 -o $OUT chmod 777 $OUT The error message says 'bad substitution', namely where OUT is defined. How to fix this? (1 Reply)
Discussion started by: figaro
1 Replies

2. UNIX for Advanced & Expert Users

Superblock marked dirty

Good morning! I met a problem on a FS with AIX 5.3 It's not possible to mount the FS because of a dirty superblock. I tried few things without success. I need your help to solve my problem guys. Do you have any idea please? Thanks a lot drp01,/home/root # mount /GSPRES/data Replaying... (9 Replies)
Discussion started by: Castelior
9 Replies

3. What is on Your Mind?

Anybody want to talk about Dirty Cow?

Hi All, How worried is everyone about the Dirty Cow Linux exploit? Has anybody experienced attacks yet? From the research I've done it seems that the exploit is "reliable" (that is it works nearly every time on vulverable systems) which is not good news. We all believe that Unix/Linux... (3 Replies)
Discussion started by: hicksd8
3 Replies
IMAGECOLORTRANSPARENT(3)						 1						  IMAGECOLORTRANSPARENT(3)

imagecolortransparent - Define a color as transparent

SYNOPSIS
int imagecolortransparent (resource $image, [int $color]) DESCRIPTION
Sets the transparent color in the given $image. PARAMETERS
o $ image -An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(3). o $color - A color identifier created with imagecolorallocate(3). RETURN VALUES
The identifier of the new (or current, if none is specified) transparent color is returned. If $color is not specified, and the image has no transparent color, the returned identifier will be -1. EXAMPLES
Example #1 imagecolortransparent(3) example <?php // Create a 55x30 image $im = imagecreatetruecolor(55, 30); $red = imagecolorallocate($im, 255, 0, 0); $black = imagecolorallocate($im, 0, 0, 0); // Make the background transparent imagecolortransparent($im, $black); // Draw a red rectangle imagefilledrectangle($im, 4, 4, 50, 25, $red); // Save the image imagepng($im, './imagecolortransparent.png'); imagedestroy($im); ?> The above example will output something similar to:[NOT DISPLAYABLE MEDIA]Output of example : imagecolortransparent() NOTES
Note Transparency is copied only with imagecopymerge(3) and true color images, not with imagecopy(3) or pallete images. Note The transparent color is a property of the image, transparency is not a property of the color. Once you have set a color to be the transparent color, any regions of the image in that color that were drawn previously will be transparent. PHP Documentation Group IMAGECOLORTRANSPARENT(3)
All times are GMT -4. The time now is 03:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy