Sponsored Content
Top Forums Shell Programming and Scripting Delete all CONSECUTIVE text lines from file shell scripting Post 302977589 by RudiC on Wednesday 20th of July 2016 06:33:52 AM
Old 07-20-2016
I was more talking of your own efforts... anyhow, try
Code:
awk '/^ *$/ {CNT = 0; print; next} ++CNT < 3 {T[CNT] = $0; next} CNT == 3 {print T[1]; print T[2]} 1' file

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search a word and delete consecutive lines below it

Hi all coders, I need a help to process some data. I have this file, 3 09/21/08 03:32:07 started undef mino Oracle nmx004.wwdc.numonyx.co m Message Text : The Oracle session with the PID 1103 has a CPU time consuming of 999.00... (3 Replies)
Discussion started by: vikas027
3 Replies

2. UNIX for Dummies Questions & Answers

Delete vertical lines in an text file

Hi everybody! I need to delete several vertical lines in a huge text file. It should work like the example below. Delete the vertical lines 2 and 8. 123456789 masldfjla afsajfwel sajfljsaf safsarfrl sajfeljwq 1345679 msldfja asajfwl sjfljsf sfsarfl sjfeljq Is there a... (11 Replies)
Discussion started by: relaxo
11 Replies

3. Shell Programming and Scripting

look for two consecutive lines in all text files

How to get (a list of) all the text files in the current directory and subdirectories which has the following two consecutive lines: ctrl_end_date=2009 ctrl_process=EXPIRED OR ctrl_end_date=2010 ctrl_process=EXPIRED i.e. (ctrl_end_date=2009 OR ctrl_end_date=2010) AND ctrl_process=EXPIRED... (6 Replies)
Discussion started by: albertkao
6 Replies

4. Shell Programming and Scripting

looking for a script that will delete lines in a text file

it will grep for a line and then delete these line. how do i begin to write this script if theres no available one? (3 Replies)
Discussion started by: garfish
3 Replies

5. Shell Programming and Scripting

how to delete two consecutive lines from the file

Hi guys I am deleting a unique line from the file and also need to remove the line above it which is NOT unique and servers as a record separator. Here is an example: # 101 803E 823F 8240 # 102 755f 4F2A 4F2B # 290 747D 0926 0927 # 999 8123 813E ... (5 Replies)
Discussion started by: aoussenko
5 Replies

6. Shell Programming and Scripting

How to delete lines from text file?

hi guys, I have very large txt files (200GB) and just want to to delete the first two lines (headers). So far I used sed -i '1,2d' infile.txtbut this command always takes extremely long as it writes all again. Is there a better way to do it (ie just to delete the lines without writing all... (2 Replies)
Discussion started by: TuAd
2 Replies

7. Shell Programming and Scripting

How to delete lines of a text file based on another text file?

I have 2 TXT files with with 8 columns in them(tab separated). First file has 2000 entries whereas 2nd file has 300 entries. The first file has ALL the lines of second file. Now I need to remove those 300 lines (which are in both files) from first file so that first file's line count become... (2 Replies)
Discussion started by: prvnrk
2 Replies

8. UNIX for Dummies Questions & Answers

Delete 26 consecutive lines in a file

I have a text file that is about 90,000 lines long. How would I delete lines 64-89, 152-177, 240-265, 328-353... etc? The sections I would like to delete are 26 lines long and the number of lines between the sections I would like to delete is 62 lines. Thanks very much in advance. (6 Replies)
Discussion started by: MDeBiasse
6 Replies

9. Shell Programming and Scripting

How to get the consecutive last 10 week day date using UNIX ksh shell scripting?

Hi, i am writing a ksh shell script to check the last month end date whether it is falling in last 10 week day date, I am not sure How to use "Mr. Perderabo's date calculator", Could you Please let me know how to use to get my requirement, I tried my own script but duplicate week day and... (5 Replies)
Discussion started by: karthikram
5 Replies

10. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies
LGFILE(5)						      BP configuration files							 LGFILE(5)

NAME
lgfile - ION Load/Go source file DESCRIPTION
The ION Load/Go system enables the execution of ION administrative programs at remote nodes: The lgsend program reads a Load/Go source file from a local file system, encapsulates the text of that source file in a bundle, and sends the bundle to a designated DTN endpoint on the remote node. An lgagent task running on the remote node, which has opened that DTN endpoint for bundle reception, receives the extracted payload of the bundle -- the text of the Load/Go source file -- and processes it. Load/Go source file content is limited to newline-terminated lines of ASCII characters. More specifically, the text of any Load/Go source file is a sequence of line sets of two types: file capsules and directives. Any Load/Go source file may contain any number of file capsules and any number of directives, freely intermingled in any order, but the typical structure of a Load/Go source file is simply a single file capsule followed by a single directive. Each file capsule is structured as a single start-of-capsule line, followed by zero or more capsule text lines, followed by a single end- of-capsule line. Each start-of-capsule line is of this form: [file_name Each capsule text line can be any line of ASCII text that does not begin with an opening ([) or closing (]) bracket character. A text line that begins with a closing bracket character (]) is interpreted as an end-of-capsule line. A directive is any line of text that is not one of the lines of a file capsule and that is of this form: !directive_text When lgagent identifies a file capsule, it copies all of the capsule's text lines to a new file named file_name that it creates in the current working directory. When lgagent identifies a directive, it executes the directive by passing directive_text to the pseudoshell() function (see platform(3)). lgagent processes the line sets of a Load/Go source file in the order in which they appear in the file, so the directive_text of a directive may reference a file that was created as the result of processing a prior file capsule line set in the same source file. Note that lgfile directives are passed to pseudoshell(), which on a VxWorks platform will always spawn a new task; the first argument in directive_text must be a symbol that VxWorks can resolve to a function, not a shell command. Also note that the arguments in directive_text will be actual task arguments, not shell command-line arguments, so they should never be enclosed in double-quote characters ("). However, any argument that contains embedded whitespace must be enclosed in single-quote characters (') so that pseudoshell() can parse it correctly. EXAMPLES
Presenting the following lines of source file text to lgsend: [cmd33.bprc x protocol ltp ] !bpadmin cmd33.bprc should cause the receiving node to halt the operation of the LTP convergence-layer protocol. SEE ALSO
lgsend(1), lgagent(1), platform(3) perl v5.14.2 2012-05-25 LGFILE(5)
All times are GMT -4. The time now is 05:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy