Remove a range of lines from a file using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove a range of lines from a file using sed
# 8  
Old 01-25-2012
Why do this in multiple passes? Why not do it in one pass? Do you want different output to appear in different files?

---------- Post updated at 10:18 AM ---------- Previous update was at 10:16 AM ----------

Crosspost. Oh, I see. That's good to know. Seeing the actual question always, always helps Smilie
This User Gave Thanks to Corona688 For This Post:
# 9  
Old 01-25-2012
Please see the post again i have updated it
# 10  
Old 01-25-2012
Quote:
Originally Posted by Corona688
Why do this in multiple passes? Why not do it in one pass? Do you want different output to appear in different files?

---------- Post updated at 10:18 AM ---------- Previous update was at 10:16 AM ----------

Crosspost. Oh, I see. That's good to know. Seeing the actual question always, always helps Smilie
Is this post for me?

I have to do multiple passes for each different value of the 1st String
# 11  
Old 01-25-2012
Quote:
Originally Posted by Andy82
I have to do multiple passes for each different value of the 1st String
Do you? Really? If you've got millions of lines as your other thread says, the performance would just be the pits, having to repeat the work 9 times...

Check your other thread.
# 12  
Old 01-25-2012
That thread is from a different user with a slightly different problem.

The files that I will be processing will not be that large.
# 13  
Old 01-25-2012
So what? There's still no good reason to do it in 9 passes unless you absolutely have to...

---------- Post updated at 11:01 AM ---------- Previous update was at 10:57 AM ----------

Why is it removing the text that says "do not remove" anyway?
# 14  
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
Login or Register to Ask a Question