Sponsored Content
Top Forums Shell Programming and Scripting awk pattern matching in place of sed Post 302879168 by electricheadx on Wednesday 11th of December 2013 03:12:39 AM
Old 12-11-2013
Sorry for the delayed response.
The search pattern will always be the section "Table Header".
An example of header would be "Output Offset 1". The target file i am scanning is made up of 100's of instances of such tables all with different headers.
The number of occurences of rows listed in the table will range from 1 to N.
I will never know beforehand the number of rows, so this is why i have always checked to see if field 2 is numeric or not. If its not numeric i know i have reached the end of the table.

Regards
Denis.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern matching sed

MSG="THERE WERE XX RECORDS IN ERROR TABLE,AAAA, WHEN LOADING THE BBBB TABLE WITH EXTRACT FROM CCCC INTO TABLES FOR , DATABASE DDDD." echo "$MSG" > /tmp/mplanmsg.$$.out I wan to replace XX with the content in $recordXX cat /tmp/mplanmsg.$$.out|sed 's/XX/\$recordXX/g'| sed... (3 Replies)
Discussion started by: leemjesse
3 Replies

2. UNIX for Dummies Questions & Answers

Pattern matching New to Sed & Awk

Hello, Despite reading the Pattern Matching chapter in the O'Reilly Sed & Awk book several times and looking at numerous examples, I cannot seem to get any kind of conditional script to work in my awk scripts! I am able to do the basic awk and grep script to capture the data but when I do with... (0 Replies)
Discussion started by: pg55
0 Replies

3. Shell Programming and Scripting

sed - matching pattern one but not pattern two

All, I have the following file: -------------------------------------- # # /etc/pam.d/common-password - password-related modules common to all services # # This file is included from other service-specific PAM config files, # and should contain a list of modules that define the services... (2 Replies)
Discussion started by: RobertBerrie
2 Replies

4. Shell Programming and Scripting

sed pattern matching

Hi all, if I have the following piece (repeating) of text within a file and I wish to delete it via sed a b c d e <tr> <td><img alt="" height="1" width="3" src="/testweb/view/browser/images/shim.gif"></td><td><img alt="" height="1" ... (4 Replies)
Discussion started by: srage
4 Replies

5. Shell Programming and Scripting

help! Pattern Matching in vi or sed

I have a bunch of conf files, that contain the fully qualified names of servers. I would like to be able to use some sort of pattern matching with sed or vi, or whatever, to pull out the fully qualified server names, and dump them in a file. It just needs to work across several unix os. So, I... (4 Replies)
Discussion started by: tabini
4 Replies

6. UNIX for Dummies Questions & Answers

Matching pattern script (sed or awk?)

Hi Guys, I am new to the forum and to scripting so bear with me. Thanks, Gary. I have 3 files - file1, file2, file3 I am trying to come up with a script that will check the output of these files and if the 1st nine fields are matched in all 3 files, echo "The following string had been... (2 Replies)
Discussion started by: gazza-o
2 Replies

7. Shell Programming and Scripting

Place digit in front of the line searching pattern using sed command

hi All, i want to add the single digit front of the line in the report file and string compare with pattern file. patter file: pattern1.txt pattern num like 4 love 3 john 2 report file: report.txt i like very much but john is good boy i will love u so after execute... (9 Replies)
Discussion started by: krbala1985
9 Replies

8. Shell Programming and Scripting

Help with sed pattern matching

Hi My log file is Testtmp2 cat Testtmp2 12:12:38 12:14:29 12:17:34 12:19:08 12:20:10 12:21:35 12:22:20 12:22:26 12:22:34 12:22:38 12:28:14 12:31:35 12:32:50 12:33:04 (3 Replies)
Discussion started by: rahkumar
3 Replies

9. Shell Programming and Scripting

Replacing lines matching a multi-line pattern (sed/perl/awk)

Dear Unix Forums, I am hoping you can help me with a pattern matching problem. What am I trying to do? I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
Discussion started by: thefang
10 Replies

10. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies
funfilters(7)							SAORD Documentation						     funfilters(7)

NAME
Funfilters - Filtering Rows in a Table SYNOPSIS
This document contains a summary of the user interface for filtering rows in binary tables. DESCRIPTION
Table filtering allows a program to select rows from an table (e.g., X-ray event list) by checking each row against one or more expres- sions involving the columns in the table. When a table is filtered, only valid rows satisfying these expressions are passed through for processing. A filter expression is specified using bracket notation appended to the filename of the data being processed: foo.fits[pha==1&&pi==2] It is also possible to put region specification inside a file and then pass the filename in bracket notation: foo.fits[@my.reg] Filters must be placed after the extension and image section information, when such information is present. The correct order is: o file[fileinfo,sectioninfo][filters] o file[fileinfo,sectioninfo,filters] where: o file is the Funtools file name o fileinfo is an ARRAY, EVENT, FITS extension, or FITS index o sectioninfo is the image section to extract o filters are spatial region and table (row) filters to apply See Funtools Files for more information on file and image section specifications. Filter Expressions Table filtering can be performed on columns of data in a FITS binary table or a raw event file. Table filtering is accomplished by means of table filter specifications. An table filter specification consists of one or more filter expressions Filter specifications also can contain comments and local/global processing directives. More specifically, a filter specification consist of one or more lines containing: # comment until end of line # include the following file in the table descriptor @file # each row expression can contain filters separated by operators [filter_expression] BOOLOP [filter_expression2], ... # each row expression can contain filters separated by the comma operator [filter_expression1], [filter_expression2], ... # the special row# keyword allows a range of rows to be processed row#=m:n # or a single row row#=m # regions are supported -- but are described elsewhere [spatial_region_expression] A single filter expression consists of an arithmetic, logical, or other operations involving one or more column values from a table. Col- umns can be compared to other columns, to header values, or to numeric constants. Standard math functions can be applied to columns. Sepa- rate filter expressions can be combined using boolean operators. Standard C semantics can be used when constructing expressions, with the usual precedence and associativity rules holding sway: Operator Associativity -------- ------------- () left to right !! (logical not) right to left ! (bitwise not) - (unary minus) right to left * / left to right + - left to right < <= > >= left to right == != left to right & (bitwise and) left to right ^ (bitwise exclusive or) left to right | (bitwise inclusive or) left to right && (logical and) left to right || (logical or) left to right = right to left For example, if energy and pha are columns in a table, then the following are valid expressions: pha>1 energy == pha (pha>1) && (energy<=2) max(pha,energy)>=2.5 Comparison values can be integers or floats. Integer comparison values can be specified in decimal, octal (using '0' as prefix), hex (using '0x' as prefix) or binary (using '0b' as prefix). Thus, the following all specify the same comparison test of a status mask: (status & 15) == 8 # decimal (status & 017) == 010 # octal (status & 0xf) == 0x8 # hex (status & 0b1111) == 0b1000 # binary The special keyword row# allows you to process a range of rows. When row# is specified, the filter code skips to the designated row and only processes the specified number of rows. The "*" character can be utilized as the high limit value to denote processing of the remain- ing rows. Thus: row#=100:109 processes 10 rows, starting with row 100 (counting from 1), while: row#=100:* specifies that all but the first 99 rows are to be processed. Spatial region filtering allows a program to select regions of an image or rows of a table (e.g., X-ray events) using simple geometric shapes and boolean combinations of shapes. For a complete description of regions, see Spatial Region Filtering. Separators Also Are Operators As mentioned previously, multiple filter expressions can be specified in a filter descriptor, separated by commas or new-lines. When such a comma or new-line separator is used, the boolean AND operator is automatically generated in its place. Thus and expression such as: pha==1,pi=2:4 is equivalent to: (pha==1) && (pi>=2&&pi<=4) [Note that the behavior of separators is different for filter expressions and spatial region expressions. The former uses AND as the oper- ator, while the latter user OR. See Combining Region and Table Filters for more information about these conventions and how they are treated when combined.] Range Lists Aside from the standard C syntax, filter expressions can make use of IRAF-style range lists which specify a range of values. The syntax requires that the column name be followed by an '=' sign, which is followed by one or more comma-delimited range expressions of the form: col = vv # col == vv in range col = :vv # col <= vv in range col = vv: # col >= vv in range col = vv1:vv2 # vv1 <= col <= vv2 in range The vv's above must be numeric constants; the right hand side of a range list cannot contain a column name or header value. Note that, unlike an ordinary comma separator, the comma separator used between two or more range expressions denotes OR. Thus, when two or more range expressions are combined with a comma separator, the resulting expression is a shortcut for more complicated boolean logic. For example: col = :3,6:8,10: is equivalent to: (col=6 && col =10) Note also that the single-valued rangelist: col = val is equivalent to the C-based filter expression: col == val assuming, of course, that val is a numeric constant. Math Operations and Functions It is permissible to specify C math functions as part of the filter syntax. When the filter parser recognizes a function call, it automat- ically includes the math.h and links in the C math library. Thus, it is possible to filter rows by expressions such as these: o (pi+pha)>(2+log(pi)-pha) o min(pi,pha)*14>x o max(pi,pha)==(pi+1) o feq(pi,pha) o div(pi,pha)>0 The function feq(a,b) returns true (1) if the difference between a and b (taken as double precision values) is less than approximately 10E-15. The function div(a,b) divides a by b, but returns NaN (not a number) if b is 0. It is a safe way to avoid floating point errors when dividing one column by another. Include Files The special @filename directive specifies an include file containing filter expressions. This file is processed as part of the overall fil- ter descriptor: foo.fits[pha==1,@foo] Header Parameters The filter syntax supports comparison between a column value and a header parameter value of a FITS binary tables (raw event files have no such header). The header parameters can be taken from the binary table header or the primary header. For example, assuming there is a header value MEAN_PHA in one of these headers, you can select photons having exactly this value using: o pha==MEAN_PHA Table filtering is more easily described by means of examples. Consider data containing the following table structure: o double TIME o int X o int Y o short PI o short PHA o int DX o int DY Tables can be filtered on these columns using IRAF/QPOE range syntax or any valid C syntax. The following examples illustrate the possi- bilities: o pha=10 o pha==10 select rows whose pha value is exactly 10 o pha=10:50 select rows whose pha value is in the range of 10 to 50 o pha=10:50,100 select rows whose pha value is in the range of 10 to 50 or is equal to 100 o pha>=10 && pha<=50 select rows whose pha value is in the range of 10 to 50 o pi=1,2&&pha>3 select rows whose pha value is 1 or 2 and whose pi value is 3 o pi=1,2 || pha>3 select rows whose pha value is 1 or 2 or whose pi value is 3 o pha==pi+1 select rows whose pha value is 1 less than the pi value o (pha==pi+1) && (time>50000.0) select rows whose pha value is 1 less than the pi value and whose time value is greater than 50000 o (pi+pha)>20 select rows in which the sum of the pi and pha values is greater than 20 o pi%2==1 select rows in which the pi value is odd Currently, integer range list limits cannot be specified in binary notation (use decimal, hex, or octal instead). Please contact us if this is a problem. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funfilters(7)
All times are GMT -4. The time now is 01:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy