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 7692899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:57:31+00:00 2026-05-31T20:57:31+00:00

I have one file (for example: test.txt), this file contains some lines and for

  • 0

I have one file (for example: test.txt), this file contains some lines and for example one line is: abcd=11
But it can be for example: abcd=12
Number is different but abcd= is the same in all case, so could anybody give me command for finding this line and remove it?

I have tried: sed -e \"/$abcd=/d\" /test.txt >/test.txt but it removes all lines from my file and I also have tried: sed -e \"/$abcd=/d\" /test.txt >/testNew.txt but it doesn’t delete line from test.txt, it only creates new file (testNew.txt) and in this file it removes my line. But it is not what I want.

  • 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-05-31T20:57:33+00:00Added an answer on May 31, 2026 at 8:57 pm

    Based on your description in your text, here is a cleaned-up version of your sed script that should work.

    Assuming a linux GNU sed

    sed -i '/abcd=/d' /test.txt 
    

    If you’re using OS-X, then you need

    sed -i "" '/abcd=/d' /test.txt 
    

    If these don’t work, then use old-school sed with a conditional mv to manage your tmpfiles.

    sed '/abcd=/d' /test.txt > test.txt.$$ && /bin/mv test.txt.$$ test.txt
    

    Notes:

    Not sure why you’re doing \"/$abcd=/d\", you don’t need to escape " chars unless you’re doing more with this code than you indicate (like using eval). Just write it as "/$abcd=/d".

    Normally you don’t need ‘-e’

    If you really want to use ‘$abcd, then you need to give it a value AND as you’re matching the string ‘abcd=’, then you can do

     abcd='abcd='
     sed -i "/${abcd}/d" /test.txt 
    

    I hope this helps.

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

Sidebar

Related Questions

By Example I have a .txt File with this content: Hello;Test;StackOverflow;I live here Hi;NoTest;StackOverflow;I
This is driving me crazy. I have this one php file on a test
If you have a path to a file (for example, /home/bob/test/foo.txt) where each subdirectory
First some background. I have a file, for simplicity's sake, let's call it test.txt.
I used to have one class for one file. For example car.cs has the
I have one audio file captured from my iphone. I want to upload this
I want to rewrite my robots.txt for all domains but main one (I have
Given: File f = new File(test.txt); this way, each time i create a reference
I have a file which contains corrupt XML, There are some garbage characters at
In my properties file I have one property, which contains a comma separated list

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.