Sponsored Content
Full Discussion: finding the nth match
Top Forums UNIX for Dummies Questions & Answers finding the nth match Post 302530962 by countryStyle on Wednesday 15th of June 2011 12:31:03 PM
Old 06-15-2011
Quote:
Originally Posted by Corona688
Make up the scenario? Is this an actual problem or are you just quizzing us?

We often get questions about getting grep to cross multiple lines, but grep doesn't. But a 1-liner in awk might be able to do it.

We can't help you until we know how your data's organized because the logic depends on that. It's not psychic and neither are we.
Yeah....I am a wanna be teacher and fulfill my fantasies by quizzing people on the internet. Go get a life....you are being difficult.

Maybe you answered my question....but you sound generally uninformed because you are being difficult: grep will not provide the nth match only.

can anyone else confirm?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Finding nth occurrence in line and replacing it

Hi, I have several files with data that have to be imported to a database. These files contain records with separator characters. Some records are corrupt (2 separators are missing) and I need to correct them prior to importing them into the db. Example: ... (5 Replies)
Discussion started by: stresing
5 Replies

2. Shell Programming and Scripting

Getting filename for Nth line pattern match

Hi, I have many scripts in particular directory. And few of the scripts have exit 0 in second line. Now i wanted to list out the scripts name which has the exit 0 in its second line I tried many options , but i can not get the filename along with the nth line pattern match :mad:. Can anyone... (14 Replies)
Discussion started by: puni
14 Replies

3. UNIX for Dummies Questions & Answers

Finding nth line across multiple files

I have several files (around 50) that have the similar format. I need to extract the 5th line from every file and output that into a text file. So far, I have been able to figure out how to do it for a single file: $ awk 'NR==5' text1.txt > results.txt OR $ sed -n '5p' text1.txt > results.txt... (6 Replies)
Discussion started by: oriqin
6 Replies

4. Shell Programming and Scripting

Finding Nth Column

Please help me how can I display every nth field present in a "|" delimited file. Ex: If a have a file with data as a|b|c|d|e|f|g|h|k|l|m|n I want to display every 3rd feild which means the output should be c f k n Please help me. (1 Reply)
Discussion started by: ngkumar
1 Replies

5. UNIX for Dummies Questions & Answers

Printing nth and n+1th line after a pattern match

Hi , I want to print the nth and n+1 lines from a file once it gets a pattern match. For eg: aaa bbb ccc ddd gh jjjj If I find a match for bbb then I need to print bbb as well as 3rd and 4th line from the match.. Please help..Is it possible to get a command using sed :) (6 Replies)
Discussion started by: saj
6 Replies

6. Answers to Frequently Asked Questions

Finding the nth Particular Week in a Month – shell script

I see lot of request posted in internet to find out the day of nth week in a Month. example: what is the date of 3rd Sunday in October What is the date of 2nd Friday in June 2012 what is the date of 4th Saturday in January 2011..etc.. The below shell script is used to find out the... (1 Reply)
Discussion started by: itkamaraj
1 Replies

7. Shell Programming and Scripting

Problem getting Nth match in sed

Hi all, I'm trying to create a sed command to get the Nth instance of an XML tag in a string, but thus far I can only ever seem to get the last one. Given an XML string: <Wrap><GrayLevel>a</GrayLevel><GrayLevel>b</GrayLevel></Wrap> I tried to do this on the command line to get each... (7 Replies)
Discussion started by: Zel2008
7 Replies

8. Shell Programming and Scripting

How to display when nth line match a pattern?

Hi All, I have sample of listing as following Database 2 entry: Database alias = PXRES Database name = PXRES Local database directory = /db2/data1/db2phnx Database release level = d.00 Comment ... (3 Replies)
Discussion started by: ckwan
3 Replies

9. Shell Programming and Scripting

sed : replace Nth match in a file

I have a situation where a file "config.txt" looks like this Servername: OS: Serername: OS: Servername: OS: .... .... ... Servername: OS: looking for the sed syntax to replace the "Nth" occurrence of Servername (i would apply the same logic to OS as well), want to replace the Nth... (4 Replies)
Discussion started by: alldbest
4 Replies

10. AIX

Print nth previous line after match

Please help me print nth line after match awk or sed one line command. (3 Replies)
Discussion started by: sushma123
3 Replies
Tangram::Expr(3pm)					User Contributed Perl Documentation					Tangram::Expr(3pm)

NAME
Tangram::Expr - represent expressions on database server side SYNOPSIS
my ($r1, $r2) = $storage->remote(qw( ... )); $r1->{field} operator $value $r1->{field} operator $r2->{field2} $r1->{collection}->includes( $obj ) $r1->{collection}->exists( $obj, $filter ) $r1->{collection}->includes_or( $obj1, $obj2, ... ) DESCRIPTION
Tangram::Expr objects represent expressions that will be evaluated on the database server side. Expression objects fall into one of the following categories: numeric, string, reference or collection. Many of the methods in Expr are needed only by people extending Tangram. See also Tangram::Relational, and the source the Tangram::mysql and Tangram::Sybase for examples on how these functions are intercepted to allow RDBMS-specific expressions. NUMERIC EXPRESSIONS
Numeric expression objects can be compared using the operators ==, !=, <, >, <= and >=. The other operand must be either another numeric expression object, or a normal Perl numeric value. The result of the comparison is a Filter. STRING EXPRESSIONS
String expression objects can be compared using the operators eq, ne, lt, gt, le, and ge. The other operand must be either a string expression object or any Perl scalar value. Tangram will automatically quote the operand as required by the SQL syntax. The result of the comparison is a Tangram::Expr::Filter. String expression objects also support the method like($str), where $str is a string that may contain SQL wildcards. The result is a Tan- gram::Expr::Filter that translates to a SQL "LIKE $str" predicate. REFERENCE EXPRESSIONS
Reference expression objects can be compared for equality using operators == and !=. The other operand must be another reference expres- sion, a persistent object or undef(). The result of the comparison is a Filter. COLLECTION EXPRESSIONS
Collection expression objects represents a collection inside an object. It supports the includes() and exists() methods, which returns a Tangram::Expr::Filter stating that the collection must contain the operand. exists() uses a subselect. It also supports the includes_or() methods, which accepts a list and is performs a logical OR - using the IN (x,y,z) SQL construct. The operand may be a Tangram::Remote, a persistent object, or an object ID. operator < is provided as a synonym for includes(). The includes() method can be used for all collection types (Set, Array, Hash, and the Intr* versions). PREDICATES
Predicate objects represent logical expressions, or conditions. Predicates support logical operators &, | and !. Note that a single amper- sand or vertical bar must be used (this is a Perl limitation). The result is another predicate. CLASS METHODS
new($type, $expr, @remotes) Returns a new instance. $type is a Type object corresponding to this expression (see Tangram::Type). $expr is a SQL expression. It will eventually become part of a WHERE-CLAUSE. @remotes contains the Remote objects (see Tangram::Remote) that participate in the expression. Tangram uses this list to insert the corre- sponding tables in the FROM clause and conditions in the WHERE-CLAUSE. INSTANCE METHODS
expr() Returns the SQL equivalent for this expression. type() Returns the Type (see Tangram::Type) corresponding to this expression. objects() Returns the list of the objects that participate in this expression. storage() Returns the Storage associated with this expression. EXAMPLES
$person is called 'Homer' $person->{name} eq 'Homer' $person's name ends with 'mer' $person->{name}->like('%mer'); $person is older than 35 $person->{age} > 35 $person is married to $homer $person->{partner} == $homer $person is not $homer $person != $homer $person is not $homer and is older than 65 $person != $homer & $person->{age} > 65 $person is $bart's parent $person->{children}->includes( $bart ) $person->{children} < $bart $person is not $bart's parent !$person->{children}->includes( $bart ) !($person->{children} < $bart) $person is one of the local list of people, @person $person->in(@person) SEE ALSO
Tangram::Remote, Tangram::Expr, Tangram::Storage perl v5.8.8 2006-03-29 Tangram::Expr(3pm)
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy