LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Shell Script: Delete lines til string found or until particular string. (https://www.linuxquestions.org/questions/linux-general-1/shell-script-delete-lines-til-string-found-or-until-particular-string-608086/)

bhargav_crd 12-20-2007 06:11 AM

Shell Script: Delete lines til string found or until particular string.
 
Hi frnds,

I want a shell command to do following task ( A bit urgent ).
I want to delete from 1'st line to the line contains particular string.
Ex:

file1.txt
==========================
abc def
ghi j
klm nop
r st
uv
wxyz
==========================

if my input is "klm", then my output should be
file1.txt
==========================
klm nop
r st
uv
wxyz
==========================

Say my input is "uv", then my output should be
file1.txt
==========================
uv
wxyz
==========================


A bit urgent.
Plzz consider.

sed/more will help???
i tried sed.

NOTE: I want to do same recursvely. Ned to check all files in current path.

Thx
Bhargav

trickykid 12-20-2007 07:46 AM

Please do not mark your threads as urgent for the following reasons:

1. Your thread has no priority over other threads created by members.
2. It's a free site, there's not guaranteed solution to answers, you might not even get a reply at times.
3. Using a more descriptive title of the actual question or problem will get you more exposure.

Basically, most members here helping people like you out of their own spare and free time will ignore threads that say urgent in them. There's no reason to ever mark your own questions as a higher priority than anyone else's seeking help here.

If you have any questions, please read the FAQ, Rules and this thread http://www.linuxquestions.org/questi...95#post1730795 that basically goes over how to properly title your thread.

I've edited your title to something more appropriate and descriptive.

pixellany 12-20-2007 07:58 AM

http://www.grymoire.com/Unix/Sed.html

Take a look at addresses---eg sed '1,34 d' would remove the first 34 lines

bhargav_crd 12-20-2007 11:14 PM

Dear trickykid,
I'm sorry for that.
And thanks.

Dear pixellany,
Thank you.
sed '1,34 d' is pure static way.
But i need dynamic way.
My input is string. not line numbers.

Thanks
Bhargav


All times are GMT -5. The time now is 11:43 PM.