Sponsored Content
Top Forums Shell Programming and Scripting Inserting blank lines after string change Post 302599758 by chrisjorg on Saturday 18th of February 2012 08:27:29 AM
Old 02-18-2012
Inserting blank lines after string change

My input data looks like this
Code:
...
-150 120 8
-150 122 7
-150 124 11
-150 126 8
-150 128 19
-150 130 13
-150 132 26
-150 134 38
-150 136 45
-150 138 62
-150 140 75
-150 142 110
-150 144 139
-150 146 138
-150 148 158
-150 150 173
-150 152 217
-150 154 256
-150 156 268
-150 158 280
-150 160 281
-150 162 309
-150 164 325
-150 166 313
-150 168 297
-150 170 258
-150 172 203
-150 174 203
-150 176 175
-150 178 125

-148 -136 1
-148 -138 1
-148 -140 1
-148 -142 2
-148 -144 2
-148 -146 1
-148 -148 5
-148 -150 5
-148 -152 4
-148 -154 7
-148 -156 8
-148 -158 8
-148 -160 14
-148 -162 11
-148 -164 18
-148 -166 31
-148 -168 35
-148 -170 67
-148 -172 85
-148 -174 88
-148 -176 106
-148 -178 139
-148 -40 1
-148 -44 1
-148 -52 1
-148 -60 1
-148 -62 1
-148 -64 1
-148 -74 1
-148 -96 1
-148 104 1
-148 110 1
-148 114 1
-148 116 3
-148 118 2
-148 120 8
-148 122 6
-148 124 9
-148 126 13
-148 128 23
-148 130 30
-148 132 36
-148 134 37
-148 136 53
-148 138 78
-148 140 80
-148 142 119
-148 144 134
-148 146 173
-148 148 196

..,

Every time the string changes in $1 (from -150 to -148 to -146 etc.) I wish to separate the change by a blank line. Any idea on how this might be done?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

change of a string in different lines

hello, i have a dynamic file, which is generated by an ORACLE tool. Now i want to change a string, which begins with TABLESPACE following by "Name of Tablespace". The name of the new TABLESPACE is static. Example: TABLESPACE new : APPLI old: TABLESPACE "AMITTEL" new: TABLESPACE "APPLI" ... (4 Replies)
Discussion started by: bora99
4 Replies

2. Shell Programming and Scripting

Find a string and place two blank lines

Hi friends, I am looking for a line to find a particular string in my file and once found then replace with 2-3 blank lines before the string Example: aaa 11 bbb 1 2 3 aaa 22 bbb 4 5 6 Output (4 Replies)
Discussion started by: shaliniyadav
4 Replies

3. Shell Programming and Scripting

Print lines after the search string until blank line is found

All I want is to look for the pattern in the file...If I found it at # places... I want print lines after those pattern(line) until I find a blank line. Log EXAMPLE : MT:Exception caught The following Numbers were affected: 1234 2345 2346 Error java.lang.InternalError:... (3 Replies)
Discussion started by: prash184u
3 Replies

4. Shell Programming and Scripting

Delete blank lines, if blank lines are more than one using shell

Hi, Consider a file named "testfile" The contents of file are as below first line added for test second line added for test third line added for test fourth line added for test fifth line added for test (5 Replies)
Discussion started by: anil8103
5 Replies

5. Shell Programming and Scripting

Insert a string instead of blank lines

how can i insert a string sush as "###" instead of blank lines in a file? i try this code but it doesn't work! awk 'NF<1 {$1=="###" ; print$0}' in_file > out_file (13 Replies)
Discussion started by: oreka18
13 Replies

6. Shell Programming and Scripting

Inserting new line if two sequential lines begin with the same string

Hi I have a file like this: Peter North Mary Peter North Peter Borough Mary I need there to put 'X' (or anything) on a new line between the two lines where 'Peter' begins the line. There will be many matches to this string, but they will always begin with 'Peter'. Ie, the resulting... (2 Replies)
Discussion started by: majormajormajor
2 Replies

7. Shell Programming and Scripting

Inserting blank columns in already present CSV file

Hi, i have a csv file which have headers and values of it like below : headers --> CI Ref SerialNumber LastScanDate values --> VMware-42,VMware-42,Tue, 20 May 2014 11:03:44 +0000 i want to have a above csv in below format : headers --> CI Name CI Description CI Ref... (6 Replies)
Discussion started by: omkar.jadhav
6 Replies

8. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies

9. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : ®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

10. UNIX for Beginners Questions & Answers

Inserting a blank line at the end of a .txt file?

Hi there, I am having this problem: a) I am uploading a txt file from windows (notepad) with some Gaussian 09 command lines; b) Gaussian needs in certain command files, that those files have a blank line at the end of the file! c) I open the command file with vi and no blank line at the of... (2 Replies)
Discussion started by: luismga
2 Replies
IMAGECOLORCLOSEST(3)							 1						      IMAGECOLORCLOSEST(3)

imagecolorclosest - Get the index of the closest color to the specified color

SYNOPSIS
int imagecolorclosest (resource $image, int $red, int $green, int $blue) DESCRIPTION
Returns the index of the color in the palette of the image which is "closest" to the specified RGB value. The "distance" between the desired color and each color in the palette is calculated as if the RGB values represented points in three- dimensional space. If you created the image from a file, only colors used in the image are resolved. Colors present only in the palette are not resolved. PARAMETERS
o $ image -An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(3). o $red -Value of red component. o $green -Value of green component. o $blue -Value of blue component. The colors parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF. RETURN VALUES
Returns the index of the closest color, in the palette of the image, to the specified one EXAMPLES
Example #1 Search for a set of colors in an image <?php // Start with an image and convert it to a palette-based image $im = imagecreatefrompng('figures/imagecolorclosest.png'); imagetruecolortopalette($im, false, 255); // Search colors (RGB) $colors = array( array(254, 145, 154), array(153, 145, 188), array(153, 90, 145), array(255, 137, 92) ); // Loop through each search and find the closest color in the palette. // Return the search number, the search RGB and the converted RGB match foreach($colors as $id => $rgb) { $result = imagecolorclosest($im, $rgb[0], $rgb[1], $rgb[2]); $result = imagecolorsforindex($im, $result); $result = "({$result['red']}, {$result['green']}, {$result['blue']})"; echo "#$id: Search ($rgb[0], $rgb[1], $rgb[2]); Closest match: $result. "; } imagedestroy($im); ?> The above example will output something similar to: #0: Search (254, 145, 154); Closest match: (252, 150, 148). #1: Search (153, 145, 188); Closest match: (148, 150, 196). #2: Search (153, 90, 145); Closest match: (148, 90, 156). #3: Search (255, 137, 92); Closest match: (252, 150, 92). SEE ALSO
imagecolorexact(3), imagecolorclosestalpha(3), imagecolorclosesthwb(3). PHP Documentation Group IMAGECOLORCLOSEST(3)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy