LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Delete specific Range of lines Using sed , awk, grep etc. (https://www.linuxquestions.org/questions/linux-newbie-8/delete-specific-range-of-lines-using-sed-awk-grep-etc-630683/)

joyds219 03-26-2008 01:18 AM

Delete specific Range of lines Using sed , awk, grep etc.
 
hi,
My issue is that I want to delete a range of lines from a txt file Using shell scripting.For example in a file containing 100 lines, I want to delete only specific lines in the range of 11 to 29 .I can use any command for this purpose in shell script. Somebody please suggest a solution

line no. 10 contains
10 <Help
11 Name ="Maintenance Department"
12 Help="">
13 >Text
14 ...............
15 <F1
16 ...........
17 .........
18
19 <text
20 .........
21 ...........
22 <F1>
23 ...........
24 .........
25 <text
26 .........
27 ...........
28 </Help>
29 <Help
30 Name ="Clearing Department"
31 Help="">
32 >Text
33 ...............
34 <F1
35 ...........
36 .........


Is there anyone who can help me out

Tinkster 03-26-2008 01:54 AM

If you mentioned WHICH lines in that range you'd like
to remove, maybe?




Cheers,
Tink

syg00 03-26-2008 02:06 AM

Sounds like homework to me Tink ...

joyds219 03-28-2008 08:01 AM

The command to be used was
sed '2,10d' a.org > b.txt
this would delete line ranging from 2 to 10 including them.
It looks so easy. but it came after a lot of research

pixellany 03-28-2008 08:59 AM

Quote:

Originally Posted by joyds219 (Post 3103047)
The command to be used was
sed '2,10d' a.org > b.txt
this would delete line ranging from 2 to 10 including them.
It looks so easy. but it came after a lot of research

Congratulations!! Homework or not, you are on the path to total success. Look also at addressing by content---not just line number.
eg:
sed '/text/,/F1/d oldfile > newfile


All times are GMT -5. The time now is 03:20 AM.