The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #8 (permalink)  
Old 12-02-2009
Registered User
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,125

Code:
while(<DATA>){
	$n++ if /COD1/;
	if ($n == 3){
		print $.;
		exit;
	}
}
__DATA__
COD1
COD2
COD2
COD1
COD2
COD2
COD1

Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to find the number of tab delimiters in a line poornimajayan UNIX for Dummies Questions & Answers 5 09-29-2008 11:36 AM
echo a line number when script is executing gavineq UNIX for Dummies Questions & Answers 1 06-20-2008 05:11 PM
Adding a columnfrom a specifit line number to a specific line number Ezy Shell Programming and Scripting 2 05-12-2008 09:29 AM
Appending line number to each line and getting total number of lines chiru_h Shell Programming and Scripting 2 03-25-2008 10:19 AM
Unix Script with line number at beginning of each line. mascorro Shell Programming and Scripting 5 06-19-2006 05:34 PM



All times are GMT -4. The time now is 11:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0