Sponsored Content
Top Forums Shell Programming and Scripting Remove a range of lines from a file using sed Post 302593042 by Andy82 on Wednesday 25th of January 2012 12:14:52 PM
Old 01-25-2012
Think there is a miss understanding.

It is not removing the text that says do not remove. It is leaving it untouched.

Can multiple ranges be passed into sed? I know there is the -e option but I did not think this worked with ranges.

It still leaves me with the issue of stoping sed when it finds the second string in the range.
 

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

Remove strings within range using sed

Hey folks I have a big file that contains junk data between the tags <point> and </point> and I need to delete it (including `<point>' and `</point>'). i.e. a = 1 <point> 123123 2342352 234231 234256 </point> print a needs to become a = 1 print a I'm certain that this is a... (10 Replies)
Discussion started by: ksk
10 Replies

3. Shell Programming and Scripting

grep/sed to remove lines in file

Hi, I have a file with values, file1: BELL-1180-1180-81|577:1017| BELL-1180-1180-81|jm10i-auto-stub1/577:102| BELL-1180-1180-81|jm10i-auto-stub1/577:101| BELL-1180-1180-81|jm10i-auto-stub1/577:1700| BELL-1180-1180-81|jm10i-auto-stub1/577:1699| I need to remove the lines which has... (9 Replies)
Discussion started by: giri_luck
9 Replies

4. Shell Programming and Scripting

Sed print range of lines between line number and pattern

Hi, I have a file as below This is the line one This is the line two <\XMLTAG> This is the line three This is the line four <\XMLTAG> Output of the SED command need to be as below. This is the line one This is the line two <\XMLTAG> Please do the need to needful to... (4 Replies)
Discussion started by: RMN
4 Replies

5. Shell Programming and Scripting

sed filtering lines by range fails 1-line-ranges

The following is part of a larger project and sed is (right now) a given. I am working on a recursive Korn shell function to "peel off" XML tags from a larger text. Just for context i will show the complete function (not working right now) here: function pGetXML { typeset chTag="$1" typeset... (5 Replies)
Discussion started by: bakunin
5 Replies

6. Shell Programming and Scripting

Using sed in a loop/to remove lines contained in variable from file

I've tried numerous commands, but I am not sure how to use sed in a loop. This is what I have: VARZ contains CARD_FILE_LIST and it also contains CARD_FILE_LIST2 so echo "$VARZ" CARD_FILE_LIST CARD_FILE_LIST2 I have a file with 60 lines in /tmp/testfile it and I want those lines deleted... (3 Replies)
Discussion started by: newbie2010
3 Replies

7. Shell Programming and Scripting

sed to remove all lines in file that are not .vcf.gz extention

I am trying to use sed to remove all lines in a file that are nor vcf.gz. The sed below runs but returns all the files with vcf.gz in them, rather then just the ones that end in only that extention. Thank you :). file ... (9 Replies)
Discussion started by: cmccabe
9 Replies

8. Shell Programming and Scripting

How to remove repetitive lines in a file with sed?

Hello, My goal is the make all x times repeated lines into a single line. I need to attain the expected output with sed -i , I need to overwrite the MyFile MyFile: Hello World Welcome Hello World Welcome Back This is my test Expected output: Hello World Welcome Welcome Back This is... (6 Replies)
Discussion started by: baris35
6 Replies

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

10. UNIX for Beginners Questions & Answers

Sed/awk to delete a regex between range of lines

Hi Guys I am looking for a solution to one problem to remove parentheses in a range of lines. Input file module bist_logic_inst(a, ab , dhd, dhdh , djdj, hdh, djjd, jdj, dhd, dhp, dk ); input a; input ab; input dhd; input djdj; input dhd; output hdh; output djjd; output jdj;... (5 Replies)
Discussion started by: kshitij
5 Replies
Number::Range(3pm)					User Contributed Perl Documentation					Number::Range(3pm)

NAME
Number::Range - Perl extension defining ranges of numbers and testing if a number is found in the range. You can also add and delete from this range. SYNOPSIS
use Number::Range; my $range = Number::Range->new("-10..10,12,100..120"); if ($range->inrange("13")) { print "In range "; } else { print "Not in range "; } $range->addrange("200..300"); $range->delrange("250..255"); my $format = $range->range; # $format will be '-10..10,12,100..120,200..249,256..300' DESCRIPTION
Number::Range will take a description of a range, and then allow you to test on if a number falls within the range. You can also add and delete from the range. RANGE FORMAT The format used for range is pretty straight forward. To separate sections of ranges it uses a "," or whitespace. To create the range, it uses ".." to do this, much like Perl's own binary ".." range operator in list context. METHODS new $range = Number::Range->new("10..20","25..30"); Creates the range object. It will accept any number of ranges as its input. addrange $range->addrange("22"); This will also take any number of ranges as input and add them to the existing range. delrange $range->delrange("10"); This will also take any number of ranges as input and delete them from the existing range. inrange $range->inrange("26"); my @results = $range->inrange("27","200"); This will take one or more numbers and check if each of them exists in the range. If passed a list, and in array context, it will return a list of 0's or 1's, depending if that one was true or false in the list position. If in scalar context, it will return a single 1 if all are true, or a single 0 if one of them failed. range $format = $range->range; @numbers = $range->range; Depending on context this will return either an array of all the numbers found in the range, for list context. For scalar context it will return a range string. size $size = $range->size; This will return the total number of entries in the range. EXPORT None by default. SEE ALSO
Number::Tolerant, Tie::RangeHash, and Array::IntSpan for similar modules. AUTHOR
Larry Shatzer, Jr., <larrysh@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2004-12 by Larry Shatzer, Jr. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-20 Number::Range(3pm)
All times are GMT -4. The time now is 05:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy