Sponsored Content
Top Forums Shell Programming and Scripting Remove strings within range using sed Post 302439907 by kurumi on Saturday 24th of July 2010 10:17:58 PM
Old 07-24-2010
Code:
#!/bin/bash

declare -i flag
flag=0
while read -r LINE
do
  case "$LINE" in
   *"</point>"*)
      LINE=${LINE##*</point>}
      flag=0
      ;;
   *"<point>"*)
      LINE=${LINE%%<point>*}
      echo "$LINE"
      flag=1
      ;;
  esac
  [[ $flag = 1 ]] && continue
  [[ $flag = 0 ]] && echo "$LINE"
done < "file"

Code:
# cat file
a = 1
some text here , don't delete <point>
 123123
 2342352
 234231
 234256
</point> some text here  too that cannot be deleted
print a

linux$ ./myscript.sh
a = 1
some text here , don't delete
 some text here  too that cannot be deleted
print a

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove range part of a file with sed

Hello, I would like to remove a range from a file with sed or any script command that is appropriate The section start by and finish by and I would like to keep line Could you tell me which command I should type ? Thanks a lot, Franck My input file is like this... (1 Reply)
Discussion started by: mfranck
1 Replies

2. Shell Programming and Scripting

sed: remove characters between and including 2 strings

I have the following line: 4/23/2010 0:00:38.000: Copying $$3MSYDDC02$I would like to use sed (or similiar) to remove everthing between and including $ that appears in the line so it ends up like this. 4/23/2010 0:00:38.000: Copying 3MSYDDC02I have been trying these but i'm really just... (5 Replies)
Discussion started by: jelloir
5 Replies

3. Shell Programming and Scripting

Sed: Remove whitespace between two strings

I have a 13 number string, some whitespace, and then /mp3. I need to join them. Everyline that I need this for begins with "cd" (without the quotes). What it looks like now: cd media/Audio/WAVE/9781933976334 /mp3 What I want my output to be: cd media/Audio/WAVE/9781933976334/mp3 The 13... (7 Replies)
Discussion started by: glev2005
7 Replies

4. Shell Programming and Scripting

any savant ? using AWK/SED to remove newline character between two strings : conditional removal

I'd like to remove (do a pattern or precise replacement - this I can handle in SED using Regex ) ---AFTER THE 1ST Occurrence ( i.e. on the 2nd occurrence - from the 2nd to fourth occurance ) of a specific string : type 1 -- After the 1st occurrence of 1 string1 till the 1st occurrence of... (4 Replies)
Discussion started by: sieger007
4 Replies

5. Shell Programming and Scripting

Remove a range of lines from a file using sed

Hi I am having some issue editing a file in sed. What I want to do is, in a loop pass a variable to a sed command. Sed should then search a file for a line that matches that variable, then remove all lines below until it reaches a line starting with a constant. I have managed to write a... (14 Replies)
Discussion started by: Andy82
14 Replies

6. Shell Programming and Scripting

awk or sed script to remove strings

Below am trying to separate FA-7A:1, In output file it should display 7A 1 Command am using Gives same output as below format: 22B7 10000000c9720873 0 22B7 10000000c95d5d8b 0 22BB 10000000c97843a2 0 22BB 10000000c975adbd 0 Not showing FA ports as required format... (5 Replies)
Discussion started by: aix_admin_007
5 Replies

7. Shell Programming and Scripting

USING sed to remove multiple strings/words from a line

Hi I use sed comnand to remove occurance of one workd from a line. However I need to removed occurance of dufferent words in ne line. Original-1 Hi this is the END of my begining Comand sed s/"END"/"start"/g Output-1 Hi this is the start of my beginig But I have more... (9 Replies)
Discussion started by: mnassiri
9 Replies

8. Shell Programming and Scripting

sed or awk to remove specific column to one range

I need to remove specific column to one range source file 3 1 000123456 2 2 000123569 3 3 000123564 12 000123156 15 000125648 128 000125648 Output required 3 000123456 2 000123569 3 000123564 12 000123156 15 000125648 128 000125648 (6 Replies)
Discussion started by: ranjancom2000
6 Replies

9. UNIX for Beginners Questions & Answers

Search for Multiple strings in a given date range and print the Group if they exists

Hi, I am Searching for Multiple strings in a given date range and print the Group if they exists. the below is the format: ------------------------------------------------------------------------------------------------------------------------- ID: FIRST ID MESSAGE: Event Message... (5 Replies)
Discussion started by: linuxuser999
5 Replies

10. UNIX for Beginners Questions & Answers

Match patterns between two files and extract certain range of strings

Hi, I need help to match patterns from between two different files and extract region of strings. inputfile1.fa >l-WR24-1:1 GCCGGCGTCGCGGTTGCTCGCGCTCTGGGCGCTGGCGGCTGTGGCTCTACCCGGCTCCGG GGCGGAGGGCGACGGCGGGTGGTGAGCGGCCCGGGAGGGGCCGGGCGGTGGGGTCACGTG... (4 Replies)
Discussion started by: bunny_merah19
4 Replies
DJVUXML(1)							DjVuLibre XML Tools							DJVUXML(1)

NAME
djvutoxml, djvuxmlparser - DjVuLibre XML Tools. SYNOPSIS
djvutoxml [options] inputdjvufile [outputxmlfile] djvuxmlparser [inputxmlfile] DESCRIPTION
The DjVuLibre XML Tools provide for editing the metadata, hyperlinks and hidden text associated with DjVu files. Unlike djvused(1) the DjVuLibre XML Tools rely on the XML technology and can take advantage of XML editors and verifiers. DJVUTOXML
Program djvutoxml creates a XML file outputxmlfile containing a reference to the original DjVu document inputdjvufile as well as tags describing the metadata, hyperlinks, and hidden text associated with the DjVu file. The following options are supported: --page pagenum Select a page in a multi-page document. Without this option, djvutoxml outputs the XML corresponding to all pages of the document. --with-text Specifies the HIDDENTEXT element for each page should be included in the output. If specified without the --with-anno flag then the --without-anno is implied. If none of the --with-text, --without-text, --with-anno, or --without-anno, flags are specified, then the --with-text and --with-anno flags are implied. --without-text Specifies not to output the HIDDENTEXT element for each page. If specified without the --without-anno flag then the --with-anno flag is implied. --with-anno Specifies the area MAP element for each page should be included in the output. If specified without the --with-text flag then the --without-text flag is implied. --without-anno Specifies the area MAP element for each page should not be included in the output. If specified without the --without-text flag then the --with-text flag is implied. DJVUXMLPARSER
Files produced by djvutoxml can then be modified using either a text editor or a XML editor. Program djvuxmlparser parses the XML file inputxmlfile and modifies the metadata of the DjVu files referenced by the OBJECT elements. DJVUXML DOCUMENT TYPE DEFINITION
The document type definition file (DTD) /usr/share/djvu/pubtext/DjVuXML-s.dtd defines the input and output of the DjVu XML tools. The DjVuXML-s DTD is a simplification of the HTML DTD: http://www.w3c.org/TR/1998/REC-html40-19980424/sgml/dtd.html with a few new attributes added specific to DjVu. Each of the specified pages of a DjVu document are represented as OBJECT elements within the BODY element of the XML file. Each OBJECT element may contain multiple PARAM elements to specify attributes like page name, resolu- tion, and gamma factor. Each OBJECT element may also contain one HIDDENTTEXT element to specify the hidden text (usually generated with an OCR engine) within the DjVu page. In addition each OBJECT element may reference a single area MAP element which contains multiple AREA elements to represent all the hyperlink and highlight areas within the DjVu document. PARAM Elements Legal PARAM elements of a DjVu OBJECT include but are not limited to PAGE for specifying the page-name, GAMMA for specifying the gamma cor- rection factor (normally 2.2), and DPI for specifying the page resolution. HIDDENTEXT Elements The HIDDENTEXT elements consists of nested elements of PAGECOLUMNS, REGION, PARAGRAPH, LINE, and WORD. The most deeply nested element specified, should specify the bounding coordinates of the element in top-down orientation. The body of the most deeply nested element should contain the text. Most DjVu documents use either LINE or WORD as the lowest level element, but any element is legal as the lowest level element. A white space is always added between WORD elements and a line feed is always added between LINE elements. Since languages such as Japanese do not use spaces between words, it is quite common for Asian OCR engines to use WORD as characters instead. MAP Elements The body of the MAP elements consist of AREA elements. In addition to the attributes listed in http://www.w3.org/TR/1998/REC-html40-19980424/struct/objects.html#edef-AREA, the attributes bordertype, bordercolor, border, and highlight have been added to specify border type, border color, border width, and high- light colors respectively. Legal values for each of these attributes are listed in the DjVuXML-s DTD. In addition, the shape oval has been added to the legal list of shapes. An oval uses a rectangular bounding box. BUGS
Perhaps it would have been better to use CC2 style sheets with standard HTML elements instead of defining the HIDDENTEXT element. CREDITS
The DjVu XML tools and DTD were written by Bill C. Riemers <docbill@sourceforge.net> and Fred Crary. SEE ALSO
djvu(1), djvused(1), and utf8(7). DjVuLibre XML Tools 11/15/2002 DJVUXML(1)
All times are GMT -4. The time now is 08:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy