Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Find a block of text and if a certain keyword exists, remove another block of text within that block Post 303046276 by MadeInGermany on Wednesday 29th of April 2020 11:37:04 AM
Old 04-29-2020
Here is one with awk:
Code:
awk '
{ blevel+=gsub("[{]","&")-gsub("[}]","&") }
blevel<dlevel { del=0 }
del==0
$1~/^type=scythe/ { del=1; dlevel=blevel }
' goob

When it meets type=scythe it deletes the following lines until it leaves the current { block }.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting text block in file

Need to delete a text block inside a file, that is marked with a start and an end pattern. Eg do not delete not delete <tag1> delete everything here here and here and here... <tag2> do not delete do not delete.... Believe sed is able to do this job but don't get it working. ... (1 Reply)
Discussion started by: andre123
1 Replies

2. UNIX for Advanced & Expert Users

awk - remove block of text, multiple actions for 'if', inline edit

I'm having a couple of issues. I'm trying to edit a nagios config and remove a host definition if a certain "host_name" is found. My thought is I would find host definition block containing the host_name I'm looking for and output the line numbers for the first and last lines. Using set, I will... (9 Replies)
Discussion started by: mglenney
9 Replies

3. Shell Programming and Scripting

Remove a block of Text at regular intervals

Hello all, I have a text files that consists of blocks of text. Each block of text represents a set of Cartesian coordinates for a molecule. Each block of text starts with a line that has a only a number, which is equal to the total number of atoms in the molecule. After this number is a line... (15 Replies)
Discussion started by: marcozd
15 Replies

4. Shell Programming and Scripting

How to insert text after a block of text?

Input: fstab is a configuration file that contains information of all the partitions and storage devices in your computer. The file is located under /etc, so the full path to this file is /etc/fstab. The >>>>> characters would be replaced by some texts. For example if i run a... (5 Replies)
Discussion started by: cola
5 Replies

5. Shell Programming and Scripting

Extract a block of text??

Hello all, I have a large output file from which I would like to extract a single block of text. An example block of text is shown below: ***** EQUILIBRIUM GEOMETRY LOCATED ***** COORDINATES OF ALL ATOMS ARE (ANGS) ATOM CHARGE X Y Z ... (10 Replies)
Discussion started by: marcozd
10 Replies

6. Shell Programming and Scripting

Filter or remove duplicate block of text without distinguishing marks or fields

Hello, Although I have found similar questions, I could not find advice that could help with our problem. The issue: We have several hundreds text files containing repeated blocks of text (I guess back at the time they were prepared like that to optmize printing). The block of texts... (13 Replies)
Discussion started by: samask
13 Replies

7. UNIX for Dummies Questions & Answers

Deleting Block of Text from a File

Hi I am looking for the way to delete the block of data for example original file line1 line2 line3 line4 line5 input file line2 line3 original file should contain line1 line4 line5 (3 Replies)
Discussion started by: rakeshkumar
3 Replies

8. Shell Programming and Scripting

Block of text replacement using sed

Hi, I have a requirement in which i need to replace text as below - <stringProp name="Recipe">&lt;AddGroup Name=&quot;1001&quot; Path=&quot;ServiceAdministration/Controls/1001/ServiceSwitches&quot;&gt; &lt;Param Name=&quot;AttributeName&quot; Value=&quot;HeaderManipRspIngressRuleSet&quot; Type=&quot;String&quot; /&gt; &lt;Param Name=&quot;Value&quot;... (0 Replies)
Discussion started by: abhitanshu
0 Replies

9. Shell Programming and Scripting

Grepping text block by block by using for loop

Hei buddies, Need ur help once again. I have a file which has bunch of lines which starts from a fixed pattern and ends with another fixed pattern. I want to make use of these fixed starting and ending patterns to select the bunch, one at a time. The input file is as follows. Hi welcome... (12 Replies)
Discussion started by: anushree.a
12 Replies

10. Shell Programming and Scripting

Extract a block of text

Hello all, I am working on a script which should parse a large file called input.txt which contains table definitions, index definitions and comments like these ones: ------------------------------------------------ -- DDL Statements for table "CMWSYS"."CMWD_TEC_SUIVI_TRT"... (12 Replies)
Discussion started by: kiki_riki_miki
12 Replies
wrjpgcom(1)							   User Commands						       wrjpgcom(1)

NAME
wrjpgcom - insert text comments into a JPEG file SYNOPSIS
wrjpgcom [-replace] [-comment text] [-cfile name] [filename] DESCRIPTION
wrjpgcom reads the named JPEG or JFIF file, or the standard input if no file is named, and generates a new JPEG or JFIF file on the stan- dard output. A comment block is added to the file. The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. Although the standard does not actually define the intended function of COM blocks, they are widely used to hold user-supplied text strings. This enables you to add annotations, titles, index terms, and so on to your JPEG files, and later retrieve the COM blocks as text. COM blocks do not interfere with the image stored in the JPEG file. The maximum size of a COM block is 64K, but you can have many COM blocks in one JPEG file. wrjpgcom adds a COM block, containing text that you provide, to a JPEG file. Ordinarily, the COM block is added after any existing COM blocks, but you can delete the old COM blocks if you wish. OPTIONS
The following options are supported: -cfile name Read the text for a new COM block from the named file. -comment text Supply the text for a new COM block on the command line. -replace Delete any existing COM blocks from the file. OPERANDS
The following operands are supported: filename The name of the JPEG file to which you want to add text comments. EXTENDED DESCRIPTION
To add only one line of comment text, use the -comment option to provide the text on the command line. Specify the comment text within quotes, so that the text is treated as a single argument. Longer comments can be read from a text file. If you specify neither the -comment nor the -cfile option, wrjpgcom reads the comment text from standard input. In such cases, you must supply an input image filename. You can enter multiple lines, up to 64KB. Type an end-of-file indicator, usually Ctrl-D, to terminate the comment text entry. wrjpgcom does not add a COM block if the provided comment string is empty. Therefore, you can use -replace -comment "" to delete all COM blocks from a file. EXAMPLES
Example 1: Adding a Short Comment to in.jpg to Produce out.jpg example% wrjpgcom -c "View of my back yard" in.jpg > out.jpg Example 2: Attaching a Long Comment Previously Stored in comment.txt example% wrjpgcom in.jpg < comment.txt > out.jpg or example% wrjpgcom -cfile comment.txt < in.jpg > out.jpg In this example, 1000 is a number that is larger than the number of rows in the source file. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWjpg | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
cjpeg(1), djpeg(1), jpegtran(1), rdjpgcom(1) NOTES
This man page was originally written by the Independent JPEG Group. Updated by Breda McColgan, Sun Microsystems Inc., 2004. SunOS 5.10 26 Mar 2004 wrjpgcom(1)
All times are GMT -4. The time now is 11:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy