Sponsored Content
Top Forums Shell Programming and Scripting Print lines after the search string until blank line is found Post 302446758 by Franklin52 on Thursday 19th of August 2010 02:31:01 PM
Old 08-19-2010
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print lines with search string at specific position

Hi Folks, I have a file with all fields defined by byte position, but any field can be empty so I cannot print lines based on a search of specific columns. I need to print all lines of this file where the string of two characters at byte position 100-101 contains the number 27. Any ideas? ... (4 Replies)
Discussion started by: HealthyGuy
4 Replies

2. Shell Programming and Scripting

How to use sed to search for string and Print previous two lines and current line

Hello, Can anybody help me to correct my sed syntax to find the string and print previous two lines and current line and next one line. i am using string as "testing" netstat -v | sed -n -e '/test/{x;2!p;g;$!N;p;D;}' -e h i am able to get the previous line current line next line but... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

3. Shell Programming and Scripting

Unix help to find blank lines in a file and print numbers on that line

Hi, I would like to know how to solve one of my problems using expert unix commands. I have a file with occasional blank lines; for example; dertu frthu fghtu frtty frtgy frgtui frgtu ghrye frhutp frjuf I need to edit the file so that the file looks like this; (10 Replies)
Discussion started by: Lucky Ali
10 Replies

4. Shell Programming and Scripting

awk print second line after search string

I have multiple config files where I need to pull the ip address from loopback3. The format is the same in every file, the ip is the second line after interface loopback3. interface loopback2 loopback description router ID ip address 192.168.1.1 interface loopback3 loopback description... (3 Replies)
Discussion started by: numele
3 Replies

5. Shell Programming and Scripting

Print #of lines after search string in a big file

I have a command which prints #lines after and before the search string in the huge file nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=0 a=10 s="STRING1" FILE The file is 5 gig big. It works great and prints 10 lines after the lines which contains search string in... (8 Replies)
Discussion started by: prash184u
8 Replies

6. Shell Programming and Scripting

search string in a file and retrieve 10 lines including string line

Hi Guys, I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same. can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies

7. Shell Programming and Scripting

Print lines between a regExp & a blank line

Hi, I have a file, say files_list, as below (o/p of ls -R cmd) $ cat files_list /remote/dir/path/to/file: sub-dir1 sub-dir2 sub-dir3 ... /remote/dir/path/to/file/sub-dir1: remote_file1.csv.tgz <blank line 1> /remote/dir/path/to/file/sub-dir2: remote_file2.csv.tgz <blank... (3 Replies)
Discussion started by: dips_ag
3 Replies

8. Shell Programming and Scripting

Search words in a line and print next 15 lines.

I have a text file ( basically a log file) and i have 2 words (alpha, beta), Now i want to search these two words in one line and then print next 15 lines in a temp file. there would be many lines with alpha and beta But I need only last occurrence with "alpha" and "beta" and next 15 lines. ... (4 Replies)
Discussion started by: kashif.live
4 Replies

9. Shell Programming and Scripting

Search string and print the above line and below lines?.

if the first string matches then print the previous line and current line and also print the following lines if the other string search matches. Input ------ TranTime 2012 10 12 The Record starts here Accountnumber: 4632473431274 TxnCode 323 TranID 329473242834 ccsdkcnsdncskd... (7 Replies)
Discussion started by: laknar
7 Replies

10. Shell Programming and Scripting

String search and print next all lines in one line until blank line

Dear all I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under. i/p file: A1/EXT "BSCABD1_21233G1" 757 130823 1157 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies
REGEXP-ASSEMBLE(1p)					User Contributed Perl Documentation				       REGEXP-ASSEMBLE(1p)

NAME
regexp-assemble - Assemble a list of regular expressions from a file SYNOPSIS
regexp-assemble -abcdfinprsStTuUvw file [...] DESCRIPTION
Assemble a list of regular expression either from standard input or a file, using the Regexp::Assemble module. OPTIONS
-a look Ahead. Insert "(?=...)" zero-width lookahead assertions in the pattern, where necessary. -b Blank. Ignore blank lines. -c Comment. Basic comment filtering. Strip off perl/shell comments ("s*#.*$/"). -d Debug. Turns on debugging output. See Regexp::Assemble for suitable values. -i Indent. Print the regular expression using and indent of n to display nesting. A.k.a pretty-printing. Implies -p. -n No newline. Do not print a newline after the pattern. Useful when interpolating the output into a templating system or similar. -p Print. Print the pattern. This is the default, however, it is required when the -t switch is enabled (because if you want to test patterns ordinarily you don't care what the the assembled pattern looks like). -r Reduce. The default behaviour is to reduce the assembled pattern. Enabling this switch causes the reduction algorithm to be switched off. This can help you determine how much reduction is performed. regexp-assemble pattern.file | wc # versus regexp-assemble -r pattern.file | wc -s Statistics. Print some statistics about the assembled pattern. The output is sent to STDERR (in order to allow the generated pattern to be redirected elsewhere). -S Statistics only. Like -s, except that the pattern itself is not output. Useful with -d 8 to see the time taken. -t Test. Test the assembled expression against the contents of a file. Each line is read from the file and is matched against the pattern. Lines that fail to match are printed. In other words, no output is good output. In this mode of operation, error status is 1 in the case of a failure, 0 if all lines matched. -T Time. Print statistics on the time taken to reduce and assemble the pattern. (This is merely a lazy person's synonym for "-d 8"). -u Unique. Carp if duplicate patterns are found. -U Unroll. Transform "a+" et al into "aa*" (which may allow additional reductions). -v Version. Print the version of the regexp-assemble script. -w Word/Whole. When testing the contents of a file with "-t", bracket the expression with "^" and "$" in order to match the whole word or line from the file. DIAGNOSTICS
Will print out a summary of the problem if an added pattern causes the assembly to fail. SEE ALSO
Regexp::Assemble AUTHOR
Copyright (C) 2004-2008 David Landgren. All rights reserved. LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-30 REGEXP-ASSEMBLE(1p)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy