Get number of lines after certain string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get number of lines after certain string
# 8  
Old 11-27-2013
Code:
awk '
         BEGIN{
               num = "one two three four five six seven eight nine ten"
                 n = split(num,A)
               for(i=1;i<=n;i++)NUM[A[i]]=i
              }
/start/,/stop/{
               if ((NUM[tolower($1)]-2)^2 == 1)
               printf "start,%d,%s,%s\n", NUM[tolower($1)], $2, $3
              }
   ' file

If you are trying in Solaris/Sun OS use nawk
This User Gave Thanks to Akshay Hegde For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies

2. Shell Programming and Scripting

Add string number to lines

So I have a file in the form > akdfvcnciejcndmdjfk > kdjkkkifjeeeeelfjfuf > fjfhchdejhfhfhfhfhfhf > skdkdhfhvnvncnccm and I would like it to come out in the form >1 akdfvcnciejcndmdjfk >2 kdjkkkifjeeeeelfjfuf >3 fjfhchdejhfhfhfhfhfhf (3 Replies)
Discussion started by: viored
3 Replies

3. Shell Programming and Scripting

Help in printing n number of lines if a search string matches in a file

Hi I have below script which is used to grep specific errors and if error string matches send an email alert. Script is working fine , however , i wish to print next 10 lines of the string match to get the details of error in the email alert Current code:- #!/bin/bash tail -Fn0 --retry... (2 Replies)
Discussion started by: neha0785
2 Replies

4. Shell Programming and Scripting

Concatenate lines with unique string AND number

In Bash using AWK or sed I need to convert the following file: ... numitem_tab0 =<p>1 KEYWORD</p><p>2 KEYWORD</p><p>3 KEYWORD</p><p>4 KEYWORD</p><p>5 KEYWORD</p>...<p>25 KEYWORD</p> subitem_tab0 =<p></p><p></p> ... numitem_tab6 =<p>1 KEYWORD</p><p>2 KEYWORD</p><p>3 KEYWORD</p><p>4 KEYWORD</p>... (2 Replies)
Discussion started by: pioavi
2 Replies

5. Shell Programming and Scripting

Merge two non-consecutive lines based on line number or string

This is a variation of an earlier post found here: unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html User Bartus11 was kind enough to solve that example. Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
Discussion started by: munkee
7 Replies

6. Shell Programming and Scripting

Reading n number of lines after finding string

I am trying to search a file for a value: "Top 30 reject reasons" and want the next 30 lines after that and output in a text file. If I knew the line number, I can use a combination of head and tail commands to get my results, but this doesn't seem to work when I don't have a line number. I... (2 Replies)
Discussion started by: oriqin
2 Replies

7. Shell Programming and Scripting

Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later. Ex. 1 some data 2 something else 3 more stuff which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies

8. UNIX for Dummies Questions & Answers

Number of lines containing a certain string

Hey I want to know if there is an option to know the number of lines containing a certain string (bit for example) in a file? Say I want to know number of lines containing only the string BIT in file xyz. I know how to get number of lines in a file by using wc -l but how do you get number of lines... (1 Reply)
Discussion started by: #moveon
1 Replies

9. Shell Programming and Scripting

How to print the number of lines from a file, the starting string should be passed`

Hi , I have file, which has the below content: line 100 a b c d line300 a s d f s line200 a s d a (3 Replies)
Discussion started by: little_wonder
3 Replies

10. Shell Programming and Scripting

searching and storing unknown number of lines based on the string with a condition

Dear friends, Please help me to resolve the problem below, I have a file with following content: date of file creation : 12 feb 2007 ==================== = name : suresh = city :mumbai #this is a blank line = date : 1st Nov 2005 ==================== few lines of some text this... (7 Replies)
Discussion started by: swamymns
7 Replies
Login or Register to Ask a Question
POLYMERGE(1gv)															    POLYMERGE(1gv)

NAME
polymerge - merge coincident vertices, collinear edges, coplanar faces in an OOGL OFF object SYNOPSIS
polymerge [-v vertex_thresh] [-e edge_thresh] [-f face_thresh] [-V] [-E] [-F] [-d] [-b] [inputfile.off] DESCRIPTION
Polymerge eliminates redundancies from polyhedral objects in OOGL's OFF format, and writes another OFF object to its standard output. (Optionally it can produce instead an input file for Brakke's Evolver.) Specifically, it combines nearly-coincident vertices, nearly- collinear edges, and nearly-coplanar faces. Vertices which aren't used on any face are deleted, as are faces with less than three ver- tices. Thresholds for approximate equality are adjustable from the command line. Options are: -v vertex_thresh Merge vertices when they're closer than vertex_thresh apart; the default is .00001. -V Don't attempt to merge vertices. -e edge_thresh Merge edges where |sin(vertex_angle)| < edge_thresh; the default is When edges are merged, the corresponding vertex is removed. -E Don't attempt to merge edges. (4OFF edges are never merged.) -f face_thresh Merge faces sharing an edge where the faces are nearly coplanar: when |sin(angle_between_face_normal_vectors)| < face_thresh. The default is .03, or about two degrees. Note that merging can create faces which are concave polygons. -F Don't attempt to merge faces. (4OFF faces are never merged.) -b Produce an output file in .fe format for Brakke's Surface Evolver, instead of a new OFF file. -d Include debugging information as comments in the new OFF object. The comments indicate which vertices and faces in the original object correspond to which in the new one. Messages include: # Vtx nnn->mmm Merged vertices nnn and mmm (both indices in the original object). # Merged face nnn into mmm (vertices vvv www) n1.n2 s Faces nnn and mmm in the original object were merged; their common edge joined original vertices vvv and www. The cosine of the angle between the face normals was s. vertex coordinates # newvertno [order] # oldvertno Each vertex written appears with its new index, its order (number of edges touching that vertex), and its old index (index of a cor- responding vertex in the original object). face description # oldvertno ... For each new face, with N vertices after reduction, the comment indicates N corresponding vertices in the original object. AUTHOR
Stuart Levy, Geometry Center, University of Minnesota SEE ALSO
anytooff(1), offconsol(1) BUGS
Coplanar faces are merged even if they were assigned different colors. Should be able to handle binary OFF objects, but this hasn't been tested. Geometry Center 25 July 1993 POLYMERGE(1gv)