Sponsored Content
Full Discussion: sed across multiple files
Top Forums UNIX for Dummies Questions & Answers sed across multiple files Post 13535 by theDirtiest on Friday 18th of January 2002 01:40:00 PM
Old 01-18-2002
true you don't need the rm temp, but I just added it so it wasn't left over when the script was finished.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use multiple files in sed with w command

i have a command like : sed -n 's/^* /&/w even' <file if i want to write to multiple files like sed -n 's/^* /&/w zero two three' < file its not working it is taking "zero two three" as a single file i want to write to 3 seperate files . pls can anyone help me (2 Replies)
Discussion started by: santosh1234
2 Replies

2. UNIX for Dummies Questions & Answers

sed on multiple files?

Hi, I want to do a search and replace on multiple text files. Can I use sed to do this? i.e. I want to do something like: $ sed *.html -e 's/<\/body>/<\!-- blah -->\n<\/body>/' | grep -1 body ... then pipe/ channel the results back into the same files that were searched. how would... (2 Replies)
Discussion started by: mgrahamnz
2 Replies

3. UNIX for Dummies Questions & Answers

SED on multiple files

Hello all, Search & replace works fine using sed on a single file. Ex: sed -i 's/day/night/g' test1.sh There are many *.sh files in my current directory that I would like use sed on. I tried running the sed command using wild card but it did not work. sed -i 's/day/night/g' *.sh ... (7 Replies)
Discussion started by: luft
7 Replies

4. UNIX for Dummies Questions & Answers

best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

Hi guys, say I have a few files in a directory (58 text files or somthing) each one contains mulitple strings that I wish to replace with other strings so in these 58 files I'm looking for say the following strings: JAM (replace with BUTTER) BREAD (replace with CRACKER) SCOOP (replace... (19 Replies)
Discussion started by: rich@ardz
19 Replies

5. Shell Programming and Scripting

SED command using multiple input files

What is the syntax to use multiple input files in a SED command. i.e. substitute a word with a phrase in every file in a directory. for every file in /usr/include that has the word "date" in the file grep -l '\<date\>' /usr/include/*.h find each occurrence of the word "time" in the file &... (3 Replies)
Discussion started by: sheoguey
3 Replies

6. Shell Programming and Scripting

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. I use the program to change an occurance of a word throughout different files that are being tested. At first i had to Create a new script,... (1 Reply)
Discussion started by: Johnny2518
1 Replies

7. Homework & Coursework Questions

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. What i have so far is !/bin/sh File1="$3" File2="$4" File3="$5" testNum="$File1" while test "$testNum" <= "$File3"; do echo... (12 Replies)
Discussion started by: Johnny2518
12 Replies

8. Homework & Coursework Questions

Shell Script to sed with Multiple Files

I am not sure what I am doing wrong here. The code should work fine. I have been making small changes insuring that each new bit works. Now running my sed through multiple files I am getting incorrect output. Any help and instruction would be greatly appreciated. The problem - Generalize... (10 Replies)
Discussion started by: Lycopene
10 Replies

9. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies

10. Shell Programming and Scripting

Using sed to edit multiple files

Created a shell script to invoke sed to edit multiple files, but am missing something. Here's the shell script: oracle:$ cat edit_scripts.sh #!/bin/sh #------------------------------------------------------------------------------ # edit_scripts.sh # # This script executes sed to make global... (4 Replies)
Discussion started by: edstevens
4 Replies
SDL_PixelFormat(3)						 SDL API Reference						SDL_PixelFormat(3)

NAME
SDL_PixelFormat- Stores surface format information STRUCTURE DEFINITION
typedef struct{ SDL_Palette *palette; Uint8 BitsPerPixel; Uint8 BytesPerPixel; Uint32 Rmask, Gmask, Bmask, Amask; Uint8 Rshift, Gshift, Bshift, Ashift; Uint8 Rloss, Gloss, Bloss, Aloss; 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 07:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy