Sponsored Content
Full Discussion: Line processing
Top Forums Shell Programming and Scripting Line processing Post 302594168 by pvamsikr on Monday 30th of January 2012 05:12:25 PM
Old 01-30-2012
Try this:

Code:
awk '{temp = $4; $4 = $16; $16 = temp} {print $0}' file

This User Gave Thanks to pvamsikr For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

processing line in file

Hi I amtrying to read the lines from a file, these lines are absolute paths in the system. I want to check if these paths exists, if they doesn't I want to create that path and put a file in that location/path. I had no trouble filtering these paths out using awk, grep, uniq etc but when it... (8 Replies)
Discussion started by: fablef00
8 Replies

2. Shell Programming and Scripting

AWK Multi-Line Records Processing

I am an Awk newbie and cannot wrap my brain around my problem: Given multi-line records of varying lengths separated by a blank line I need to skip the first two lines of every record and extract every-other line in each record unless the first line of the record has the word "(CONT)" in the... (10 Replies)
Discussion started by: RacerX
10 Replies

3. Shell Programming and Scripting

File processing line by line

Hi, I am doing file processing line by line. while reading each line at a specified location I am searching for a particular character and then write that line to another file. Problem is while writing to another file it was supressing the spaces, which I don't want to do. Any help is... (1 Reply)
Discussion started by: suma
1 Replies

4. Shell Programming and Scripting

Reading a file line by line and processing for each line

Hi, I am a beginner in shell scripting. I have written the following script, which is supposed to process the while loop for each line in the sid_home.txt file. But I'm getting the 'end of file' unexpected for the last line. The file sid_home.txt gets generated as expected, but the script... (6 Replies)
Discussion started by: sagarparadkar
6 Replies

5. Shell Programming and Scripting

reading a file inside awk and processing line by line

Hi Sorry to multipost. I am opening the new thread because the earlier threads head was misleading to my current doubt. and i am stuck. list=`cat /u/Test/programs`; psg "ServTest" | awk -v listawk=$list '{ cmd_name=($5 ~ /^/)? $9:$8 for(pgmname in listawk) ... (6 Replies)
Discussion started by: Anteus
6 Replies

6. Shell Programming and Scripting

Text Processing with a line break

Dear Masters, Need your help to process the below file named "breakline". At some places the rows are broken into two lines and each rows starts with a tab space. >cat breakline _Index 187 18.4K 92 137 100 190 1.0 3.3 _Index-Field 365 26.7K 74 76 75 365 1.0 2.5 _KeyEvent 0 0.0B 0 0 0 0... (8 Replies)
Discussion started by: patric2326
8 Replies

7. Shell Programming and Scripting

Individual Line processing in awk

Hi , I have a file like Activate your Membership now! Dear Cyrus Every relationship needs nurturing. Including ours. 2011-08-09T10:18:14Z 2011-08-09T10:18:14Z tag:gmail.google.com,2004:1376659800396305843 T League email@email.tleague.com How to refresh a graphical display through... (3 Replies)
Discussion started by: ddspark
3 Replies

8. Shell Programming and Scripting

[awk] line by line processing the same file

Hey, not too good at this, so I only managed a clumsy and SLOW solution to my problem that needs a drastic speed up. Any ideas how I write the following in awk only? Code is supposed to do... For every line read column values $6, $7, $8 and do a calculation with the same column values of every... (6 Replies)
Discussion started by: origamisven
6 Replies

9. UNIX for Advanced & Expert Users

File Processing: Handling spaces in a line

Hi All, Iam trying to get a file processed and some lines have spaces...the below is not working Want to remove empty line Want to remove lines that start with # Avoid line with substring WHOA When trying to get the substring from the var also Iam having trouble file is like VAR=VALUE,... (13 Replies)
Discussion started by: baanprog
13 Replies
SDL_PixelFormat(3)						 SDL API Reference						SDL_PixelFormat(3)

NAME
SDL_PixelFormat - Stores surface format information STRUCTURE DEFINITION
typedef struct SDL_PixelFormat { SDL_Palette *palette; Uint8 BitsPerPixel; Uint8 BytesPerPixel; Uint8 Rloss, Gloss, Bloss, Aloss; Uint8 Rshift, Gshift, Bshift, Ashift; Uint32 Rmask, Gmask, Bmask, Amask; Uint32 colorkey; Uint8 alpha; } SDL_PixelFormat; STRUCTURE DATA
palette Pointer to the palette, or NULL if the BitsPerPixel>8 BitsPerPixel The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32. BytesPerPixel The number of bytes used to represent each pixel in a surface. Usually one to four. [RGBA]mask Binary mask used to retrieve individual color values [RGBA]loss Precision loss of each color component (2^[RGBA]loss) [RGBA]shift Binary left shift of each color component in the pixel value colorkey Pixel value of transparent pixels alpha Overall surface alpha value DESCRIPTION
A SDL_PixelFormat describes the format of the pixel data stored at the pixels field of a SDL_Surface. Every surface stores a SDL_PixelFor- mat in the format field. If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential. 8-bit pixel formats are the easiest to understand. Since its an 8-bit format, we have 8 BitsPerPixel and 1 BytesPerPixel. Since BytesPer- Pixel is 1, all pixels are represented by a Uint8 which contains an index into palette->colors. So, to determine the color of a pixel in a 8-bit surface: we read the color index from surface->pixels and we use that index to read the SDL_Color structure from surface->for- mat->palette->colors. Like so: SDL_Surface *surface; SDL_PixelFormat *fmt; SDL_Color *color; Uint8 index; . . /* Create surface */ . . fmt=surface->format; /* Check the bitdepth of the surface */ if(fmt->BitsPerPixel!=8){ fprintf(stderr, "Not an 8-bit surface. "); return(-1); } /* Lock the surface */ SDL_LockSurface(surface); /* Get the topleft pixel */ index=*(Uint8 *)surface->pixels; color=fmt->palette->colors[index]; /* Unlock the surface */ SDL_UnlockSurface(surface); printf("Pixel Color-> Red: %d, Green: %d, Blue: %d. Index: %d ", color->r, color->g, color->b, index); . . Pixel formats above 8-bit are an entirely different experience. They are considered to be "TrueColor" formats and the color information is stored in the pixels themselves, not in a palette. The mask, shift and loss fields tell us how the color information is encoded. The mask fields allow us to isolate each color component, the shift fields tell us the number of bits to the right of each component in the pixel value and the loss fields tell us the number of bits lost from each component when packing 8-bit color component in a pixel. /* Extracting color components from a 32-bit color value */ SDL_PixelFormat *fmt; SDL_Surface *surface; Uint32 temp, pixel; Uint8 red, green, blue, alpha; . . . fmt=surface->format; SDL_LockSurface(surface); pixel=*((Uint32*)surface->pixels); SDL_UnlockSurface(surface); /* Get Red component */ temp=pixel&fmt->Rmask; /* Isolate red component */ temp=temp>>fmt->Rshift;/* Shift it down to 8-bit */ temp=temp<<fmt->Rloss; /* Expand to a full 8-bit number */ red=(Uint8)temp; /* Get Green component */ temp=pixel&fmt->Gmask; /* Isolate green component */ temp=temp>>fmt->Gshift;/* Shift it down to 8-bit */ temp=temp<<fmt->Gloss; /* Expand to a full 8-bit number */ green=(Uint8)temp; /* Get Blue component */ temp=pixel&fmt->Bmask; /* Isolate blue component */ temp=temp>>fmt->Bshift;/* Shift it down to 8-bit */ temp=temp<<fmt->Bloss; /* Expand to a full 8-bit number */ blue=(Uint8)temp; /* Get Alpha component */ temp=pixel&fmt->Amask; /* Isolate alpha component */ temp=temp>>fmt->Ashift;/* Shift it down to 8-bit */ temp=temp<<fmt->Aloss; /* Expand to a full 8-bit number */ alpha=(Uint8)temp; printf("Pixel Color -> R: %d, G: %d, B: %d, A: %d ", red, green, blue, alpha); . . . SEE ALSO
SDL_Surface, SDL_MapRGB SDL
Tue 11 Sep 2001, 23:01 SDL_PixelFormat(3)
All times are GMT -4. The time now is 09:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy