Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:32:52+00:00 2026-06-04T04:32:52+00:00

I have a file whose contents are like this : control_data { some data

  • 0

I have a file whose contents are like this :

control_data {
some data dadadadf 
some data fsfsfs
some more data
.
.
.
}
more data below 
{
.
.
}

I want to delete the data from “control_data” to the first “}”

I tried a command

sed "s/control_data\([^}]*\)}//g"

but this only works if we do not have multiple lines eg. this command works when we have data like:

control_data {some data dadadadf some data fsfsfs some more data...}more data

It gives :

more data {....} 

How to make this command work when we have data across multiple lines ?
I am new to shell scripting some explanation with answer will go a long way in helping.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:32:53+00:00Added an answer on June 4, 2026 at 4:32 am

    This one may not be an ideal one but this used sed(your sed code)

    cat ip_file.txt | tr '\n' ':' | sed "s/control_data\([^}]*\)}//g" | tr ':' '\n'
    

    Logic: I am converting all new lines to : and then using your sed code and then converting all : to newlines
    Note : My assumption is : wont be present in the file anywhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml file roughly like this: <batch> <header> <headerStuff /> </header> <contents>
I have a file,named f1.txt, whose contents are 75 15 85 35 60 50
I have an mp3 file on a server. I want to get this file's
I want to include an external file as a class body, something like this:
I have a TextView whose contents are copied from a text file. Now each
I have a very simple Python file, called python1.py, whose contents are: f =
I have a xml file whose content is <?xml version=1.0 encoding=UTF-8?> <ReturnMessage> <root>ReturnMessage</root> <cancelMessage>Request
Suppose I have a file X.h which defines a class X, whose methods are
I have designed a database whose MDF file will be copied to remote offices,
I have had written text file in which I have statements like these :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.