Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-20-2007, 06:11 AM   #1
LQ Newbie
Registered: Sep 2007
Posts: 8

Rep: Reputation: 0
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.

abc def
ghi j
klm nop
r st

if my input is "klm", then my output should be
klm nop
r st

Say my input is "uv", then my output should be

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.


Last edited by bhargav_crd; 12-20-2007 at 06:17 AM.
Old 12-20-2007, 07:46 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 270Reputation: 270Reputation: 270
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 that basically goes over how to properly title your thread.

I've edited your title to something more appropriate and descriptive.
Old 12-20-2007, 07:58 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743

Take a look at addresses---eg sed '1,34 d' would remove the first 34 lines
Old 12-20-2007, 11:14 PM   #4
LQ Newbie
Registered: Sep 2007
Posts: 8

Original Poster
Rep: Reputation: 0
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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script- text file manip- delete everything before/after string justin99 Programming 9 11-20-2014 03:16 AM
String Manipulations in Shell Script Programming 15 04-19-2007 10:40 AM
Shell Script - String Replacement revof11 Programming 7 11-29-2005 06:38 AM
(shell script) string parsing kuru Programming 4 09-12-2005 07:59 PM
Shell script to find a particular string Prasun1 Linux - General 5 08-30-2005 09:23 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:38 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration