Sponsored Content
Full Discussion: AWK/SED line based search
Top Forums Shell Programming and Scripting AWK/SED line based search Post 302586456 by new_one on Monday 2nd of January 2012 05:23:55 AM
Old 01-02-2012
AWK/SED line based search

Hi,

I have a file with values like this
1 11
2 11
3 44
4 55
5 66 (an representative of what I have).
I want to split this file into smaller files based on column 1 values (values within a range).

The issue that I am facing is that the file is really big, and takes too long to run.

Is there anyway that I can do this-

1. given a initial range, export the values, save the last line number.
2. start the next search from where the previous search finished.

I tried playing with NR values but turned up useless.

Or may be SED is an alternative?

HELP!!

Thanks a lot in advance Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search file, change existing value based on input (awk help)

I have a file (status.file) of the form: valueA 3450 valueB -20 valueC -340 valueD 48 I am tailing a data.file, and need to search and modify a value in status.file...the tail is: tail -f data.file | awk '{ print $3, ($NF - $(NF-1)) }' which will produce lines that look like this: ... (3 Replies)
Discussion started by: nortonloaf
3 Replies

2. Shell Programming and Scripting

sed search and replace in next line

Hello, I am hoping someone can provide some guidance on using context based search and replace to search for a pattern and then do a search and replace in the line that follows it. For example, I have a file that looks like this: <bold>bold text </italic> somecontent morecontent... (3 Replies)
Discussion started by: charissaf67
3 Replies

3. Shell Programming and Scripting

using sed to conditionally extract stanzas of a file based on a search string

Dear All, I have a file with the syntax below (composed of several <log ..... </log> stanzas) I need to search this file for a number e.g. 2348022225919, and if it is found in a stanza, copy the whole stanza/section (<log .... </log>) to another output file. The numbers to search for are... (0 Replies)
Discussion started by: aitayemi
0 Replies

4. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

5. Shell Programming and Scripting

Printing previous line based on pattern using sed

Hi, I have a written a shell script to get the previous line based on the pattern. For example if a file has below lines: ---------------------------------------------- #UNBLOCK_As _per #As per 205.162.42.92 #BLOCK_As_per #----------------------- #input checks abc.com... (5 Replies)
Discussion started by: Anjan1
5 Replies

6. Shell Programming and Scripting

Split a line based on : using sed

Hi, i have a file say file1 having following data /abc/def:ghi/jkl/ some other text Now i want to extract only ghi/jkl/using sed, can some one please help me. Thanks Sarbjit (2 Replies)
Discussion started by: sarbjit
2 Replies

7. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

8. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies

9. Shell Programming and Scripting

awk command to search based on 5 user input fields

Field1=”” Field2=”” Field3=”” Field4=”” Field5=”” USER INPUT UP TO 5 FIELDS awk -F , '{ if ( $3 == Field1 && $6 == Field2 && $8 == Field3 && $9 == Field4 && $10 == Field5) print $0 }' /tmp/rodney.outD INPUT FILE (Rodney.outD): ... (3 Replies)
Discussion started by: rmerrird
3 Replies

10. UNIX for Beginners Questions & Answers

Search a multi-line shell command output and execute logic based on result

The following is a multi-line shell command example: $cargo build Compiling prawn v0.1.0 (/Users/ag/rust/prawn) error: failed to resolve: could not find `setup_panix` in `human_panic` --> src/main.rs:14:22 | 14 | human_panic::setup_panix!(); | ... (2 Replies)
Discussion started by: yogi
2 Replies
GLMATERIAL(3G)															    GLMATERIAL(3G)

NAME
glMaterialf, glMateriali, glMaterialfv, glMaterialiv - specify material parameters for the lighting model C SPECIFICATION
void glMaterialf( GLenum face, GLenum pname, GLfloat param ) void glMateriali( GLenum face, GLenum pname, GLint param ) PARAMETERS
face Specifies which face or faces are being updated. Must be one of GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK. pname Specifies the single-valued material parameter of the face or faces that is being updated. Must be GL_SHININESS. param Specifies the value that parameter GL_SHININESS will be set to. C SPECIFICATION
void glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ) void glMaterialiv( GLenum face, GLenum pname, const GLint *params ) PARAMETERS
face Specifies which face or faces are being updated. Must be one of GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK. pname Specifies the material parameter of the face or faces that is being updated. Must be one of GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION, GL_SHININESS, GL_AMBIENT_AND_DIFFUSE, or GL_COLOR_INDEXES. params Specifies a pointer to the value or values that pname will be set to. DESCRIPTION
glMaterial assigns values to material parameters. There are two matched sets of material parameters. One, the front-facing set, is used to shade points, lines, bitmaps, and all polygons (when two-sided lighting is disabled), or just front-facing polygons (when two-sided lighting is enabled). The other set, back-facing, is used to shade back-facing polygons only when two-sided lighting is enabled. Refer to the glLightModel reference page for details concerning one- and two-sided lighting calculations. glMaterial takes three arguments. The first, face, specifies whether the GL_FRONT materials, the GL_BACK materials, or both GL_FRONT_AND_BACK materials will be modified. The second, pname, specifies which of several parameters in one or both sets will be modi- fied. The third, params, specifies what value or values will be assigned to the specified parameter. Material parameters are used in the lighting equation that is optionally applied to each vertex. The equation is discussed in the glLightModel reference page. The parameters that can be specified using glMaterial, and their interpretations by the lighting equation, are as follows: GL_AMBIENT params contains four integer or floating-point values that specify the ambient RGBA reflectance of the material. Inte- ger values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative rep- resentable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The initial ambient reflectance for both front- and back-facing materials is (0.2, 0.2, 0.2, 1.0). GL_DIFFUSE params contains four integer or floating-point values that specify the diffuse RGBA reflectance of the material. Inte- ger values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative rep- resentable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The initial diffuse reflectance for both front- and back-facing materials is (0.8, 0.8, 0.8, 1.0). GL_SPECULAR params contains four integer or floating-point values that specify the specular RGBA reflectance of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point val- ues are clamped. The initial specular reflectance for both front- and back-facing materials is (0, 0, 0, 1). GL_EMISSION params contains four integer or floating-point values that specify the RGBA emitted light intensity of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point val- ues are clamped. The initial emission intensity for both front- and back-facing materials is (0, 0, 0, 1). GL_SHININESS params is a single integer or floating-point value that specifies the RGBA specular exponent of the material. Integer and floating-point values are mapped directly. Only values in the range [0,128] are accepted. The initial specular exponent for both front- and back-facing materials is 0. GL_AMBIENT_AND_DIFFUSE Equivalent to calling glMaterial twice with the same parameter values, once with GL_AMBIENT and once with GL_DIFFUSE. GL_COLOR_INDEXES params contains three integer or floating-point values specifying the color indices for ambient, diffuse, and specular lighting. These three values, and GL_SHININESS, are the only material values used by the color index mode lighting equation. Refer to the glLightModel reference page for a discussion of color index lighting. NOTES
The material parameters can be updated at any time. In particular, glMaterial can be called between a call to glBegin and the correspond- ing call to glEnd. If only a single material parameter is to be changed per vertex, however, glColorMaterial is preferred over glMaterial (see glColorMaterial). While the ambient, diffuse, specular and emission material parameters all have alpha components, only the diffuse alpha component is used in the lighting computation. ERRORS
GL_INVALID_ENUM is generated if either face or pname is not an accepted value. GL_INVALID_VALUE is generated if a specular exponent outside the range [0,128] is specified. ASSOCIATED GETS
glGetMaterial SEE ALSO
glColorMaterial(3G), glLight(3G), glLightModel(3G) GLMATERIAL(3G)
All times are GMT -4. The time now is 05:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy