Sponsored Content
Top Forums Shell Programming and Scripting Extracting line matching a phrase and then the next lines after it Post 302373261 by thegeek on Friday 20th of November 2009 12:07:27 AM
Old 11-20-2009
Quote:
Originally Posted by danmero
however your solution don't insert blank line between record blocks Smilie see OP requirement.
Code:
sed -n '/id/{p;n;p;n;G;p}' t1

This can print the 2 lines from id, and with blank line following as asked for...

But, giving two regex /id/,/date/ cannot satisfy OPs requirement as printing next X lines, if date comes before/after 2 lines...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logfile - extracting certain lines to concatenate into 1 line

I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run. I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table). Each diagnostic run... (3 Replies)
Discussion started by: BecTech
3 Replies

2. Shell Programming and Scripting

help extracting a matching pattern and next lines of match

Hi there, i'm having some problems just making an awk script (i've tried this way, but other way can be posible for sure), for the next file file.txt <register> <createProfile> <result>0</result> <description><!]></description> <msisdn>34661461174</msisdn> <inputOmvID>1</inputOmvID>... (6 Replies)
Discussion started by: vicious
6 Replies

3. Shell Programming and Scripting

Extracting a string matching a pattern from a line

Hi All, I am pretty new to pattern matching and extraction using shell scripting. Could anyone please help me in extracting the word matching a pattern from a line in bash. Input Sample (can vary between any of the 3 samples below): 1) Adaptec SCSI RAID 5445 2) Adaptec SCSI 5445S RAID 3)... (8 Replies)
Discussion started by: jharish
8 Replies

4. Shell Programming and Scripting

print range of lines matching pattern and previous line

Hi all, on Solaris 10, I'd like to print a range of lines starting at pattern but also including the very first line before pattern. the following doesn't print the range starting at pattern and going down to the end of file: cat <my file> | sed -n -e '/<pattern>{x;p;}/' I need to include the... (1 Reply)
Discussion started by: siriche
1 Replies

5. Shell Programming and Scripting

Extracting lines after nth LINE from an output

Hi all, Here is my problem for which i am breaking my head for past three days.. I have parted command output as follows.. Model: ATA WDC WD5000AAKS-0 (scsi) Disk /dev/sdb: 500GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type ... (3 Replies)
Discussion started by: selvarajvs
3 Replies

6. Shell Programming and Scripting

Deleting a matching string(line) which is also in other lines

Hi, i need help with my shell script I have a file input.txt containing the following contents /. /usr /usr/share /usr/share/doc /usr/share/doc/wine /usr/share/doc/wine/copyright /usr/share/doc/wine/changelog.Debian.gz I need output as /usr/share/doc/wine /usr/share/doc/wine/copyright... (3 Replies)
Discussion started by: Amit0991
3 Replies

7. Shell Programming and Scripting

Insert lines above matching line with content from matching

Hi, I have text file: Name: xyz Gender: M Address: "120_B_C; ksilskdj; lsudlfw" Zip: 20392 Name: KLM Gender: F Address: "65_D_F; wnmlsi;lsuod;,...." Zip:90233I want to insert 2 new lines before the 'Address: ' line deriving value from this Address line value The Address value in quotes... (1 Reply)
Discussion started by: ysrini
1 Replies

8. Shell Programming and Scripting

How to find a phrase and pull all lines that follow until the phrase occurs again?

I want to burst a report by using the page number value in the report header. Each section starts with *PAGE NO:* 1 Each section might have several pages, but the next section always starts back at 1. So I want to find the "*PAGE NO:* 1" value and pull all lines that follow until "*PAGE NO:* 1"... (4 Replies)
Discussion started by: Scottie1954
4 Replies

9. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

10. UNIX for Dummies Questions & Answers

Extracting the two lines where the first line is matched

Hi, If I have a file of something like @hg19_gold_AL122127.6-131160 GCTTCATCATGCATGGATAGGCTGGCGCCTTTCCTGAGGCCATATGCCGATGGATATG @hg19_gold_AL122127.6-131159 CTTTAATATTTCCGCCACCATCCTGAGTGAATCCCAGCAAGGACAGTCTTTGGGGATT @hg19_gold_AL122127.6-131158... (4 Replies)
Discussion started by: jyu429
4 Replies
COQ-TEX(1)						      General Commands Manual							COQ-TEX(1)

NAME
coq-tex - Process Coq phrases embedded in LaTeX files SYNOPSIS
coq-tex [ -o output-file ] [ -n line-width ] [ -image coq-image ] [ -w ] [ -v ] [ -sl ] [ -hrule ] [ -small ] input-file ... DESCRIPTION
The coq-tex filter extracts Coq phrases embedded in LaTeX files, evaluates them, and insert the outcome of the evaluation after each phrase. Three LaTeX environments are provided to include Coq code in the input files: coq_example The phrases between egin{coq_example} and end{coq_example} are evaluated and copied into the output file. Each phrase is followed by the response of the toplevel loop. coq_example* The phrases between egin{coq_example*} and end{coq_example*} are evaluated and copied into the output file. The responses of the toplevel loop are discarded. coq_eval The phrases between egin{coq_eval} and end{coq_eval} are silently evaluated. They are not copied into the output file, and the responses of the toplevel loop are discarded. The resulting LaTeX code is stored in the file file.v.tex if the input file has a name of the form file.tex, otherwise the name of the out- put file is the name of the input file with `.v.tex' appended. The files produced by coq-tex can be directly processed by LaTeX. Both the Coq phrases and the toplevel output are typeset in typewriter font. OPTIONS
-o output-file Specify the name of a file where the LaTeX output is to be stored. A dash `-' causes the LaTeX output to be printed on standard out- put. -n line-width Set the line width. The default is 72 characters. The responses of the toplevel loop are folded if they are longer than the line width. No folding is performed on the Coq input text. -image coq-image Cause the file coq-image to be executed to evaluate the Coq phrases. By default, this is the command coqtop without specifying any path which is used to evaluate the Coq phrases. -w Cause lines to be folded on a space character whenever possible, avoiding word cuts in the output. By default, folding occurs at the line width, regardless of word cuts. -v Verbose mode. Prints the Coq answers on the standard output. Useful to detect errors in Coq phrases. -sl Slanted mode. The Coq answers are written in a slanted font. -hrule Horizontal lines mode. The Coq parts are written between two horizontal lines. -small Small font mode. The Coq parts are written in a smaller font. CAVEATS
The egin... and end... phrases must sit on a line by themselves, with no characters before the backslash or after the closing brace. Each Coq phrase must be terminated by `.' at the end of a line. Blank space is accepted between `.' and the newline, but any other charac- ter will cause coq-tex to ignore the end of the phrase, resulting in an incorrect shuffling of the responses into the phrases. (The responses ``lag behind''.) SEE ALSO
coqtop (1). 29 March 1995 COQ-TEX(1)
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy