Sponsored Content
Top Forums Shell Programming and Scripting Multi-line filtering based on multi-line pattern in a file Post 302641621 by Finja on Wednesday 16th of May 2012 10:12:46 AM
Old 05-16-2012
Multi-line filtering based on multi-line pattern in a file

I have a file with data records separated by multiple equals signs, as below.

==========
RECORD 1
==========
RECORD 2
DATA LINE
==========
RECORD 3
==========
RECORD 4
DATA LINE
==========
RECORD 5
DATA LINE
==========

I need to filter out all data from this file where the record has no data lines. So in the example above, I would need RECORD 1 and RECORD 3 to be filtered out, plus the extra rows of equals signs separating them. So I would like the output to be:

==========
RECORD 2
DATA LINE
==========
RECORD 4
DATA LINE
==========
RECORD 5
DATA LINE
==========

I can get done whan I need on single lines, but I am stuck trying to match the pattern over multiple lines, and then deleting multiple lines.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multi line document to single lines based on occurance of string

Hi Guys, I am new to awk and sed, i am working multiline document, i want to make make that document into SINGLE lines based on occurace of string "dwh". here's the sample of my problem.. dwh123 2563 4562 4236 1236 78956 12394 4552 dwh192 2656 46536 231326 65652 6565 23262 16625623... (5 Replies)
Discussion started by: victor369
5 Replies

2. Shell Programming and Scripting

Search for a multi-line strings in a file

Hello I need to search for a mult-line strngs(with spaces in between and qoted) in a file1 and replace that text with Fixed string globally in file1. The strng to search for is in file2. The file is big with some 20K records. so speed and effciency is required file1: (where srch & rplc will... (7 Replies)
Discussion started by: Hiano
7 Replies

3. Shell Programming and Scripting

Print between multi line pattern

Hi, I have a file with text like this .SET WIDTH 10000 .SET MAXERROR 1 insert into new_db SELECT * FROM some_db ; +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+- .SET WIDTH 10000... (3 Replies)
Discussion started by: sol_nov
3 Replies

4. Shell Programming and Scripting

sed multiple multi line blocks of text containing pattern

Hi, I have a log file which has sessionids in it, each block in the log starts with a date entry, a block may be a single line or multiple lines. I need to sed (or awk) out the lines/blocks with that start with a date and include the session id. The files are large at several Gb. My... (3 Replies)
Discussion started by: andyatit
3 Replies

5. 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

6. Shell Programming and Scripting

Multi line extraction based on condition

Hi I have some data in a file as below ****************************** Class 1A Students absent are : 1. ABC 2. CDE 3. CPE ****************************** Class 2A Students absent are : ****************************** Class 3A Students absent are : (6 Replies)
Discussion started by: reldb
6 Replies

7. Shell Programming and Scripting

How to find all the multi line pattern and redirecting it to a file?

I've a file like this {multi line ....... ....... pattern} { some other stuff ......... } {multi line ....... ....... pattern} { some other stuff ......... } and so on (2 Replies)
Discussion started by: aamir_raihan
2 Replies

8. Shell Programming and Scripting

Help with reformat single-line multi-fasta into multi-line multi-fasta

Input File: >Seq1 ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD >Seq2 SDASDAQEQWEQeqAdfaasd >Seq3 ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG ...... Desired Output File >Seq1 ASDADAFASF ASFADGSDGF SDFSDFSDFS DFSDFSDFSD FSDFSDFSDF SD >Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies

9. Shell Programming and Scripting

Multi line log files to single line format

I want to read the log file which was generate from other command . And the output was having multi line in log files for job name and server name. But i need to make all the logs on one line Source file 07/15/2018 17:02:00 TRANSLOG_1700 Server0005_SQL ... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

10. UNIX for Beginners Questions & Answers

Search a multi-line shell command output and execute logic based on result

The following is a multi-line shell command example: $cargo build Compiling prawn v0.1.0 (/Users/ag/rust/prawn) error: failed to resolve: could not find `setup_panix` in `human_panic` --> src/main.rs:14:22 | 14 | human_panic::setup_panix!(); | ... (2 Replies)
Discussion started by: yogi
2 Replies
FL-RECORD(1)							   Debian manual						      FL-RECORD(1)

NAME
fl-record - records a live funkload test using TCPWatch SYNOPSIS
fl-record [ options ] test_case DESCRIPTION
fl-record uses TCPWatch to setup a proxy server which is then used by a browser and records activities. It generates a Funkload script or a unit test if a name is passed to the script. OPTIONS
--version Show program's version number and exit --help, -h Show a help message and exit --verbose, -v Verbose output --port=PORT, -p PORT TCP port where the proxy listens (Defaults to 8090) --tcp-watch-input=TCPWATCH_PATH, -i TCPWATCH_PATH Path to an existing TCPWatch capture --loop=LOOP, -l LOOP Loop mode SEE ALSO
fl-build-report(1), fl-credential-ctl(1), fl-install-demo(1), fl-monitor-ctl(1), fl-run-bench(1), fl-run-test(1). AUTHOR
Funkload was written by Benoit Delbosc. This manual page was written by Jose Parrella <bureado@debian.org>, for the Debian project (but may be used by others). Debian Project 26 March 2009 FL-RECORD(1)
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy