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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:13:16+00:00 2026-06-04T11:13:16+00:00

Bashing trouble in MSYS: The following simple function should delete all lines that match

  • 0

Bashing trouble in MSYS: The following simple function should delete all lines that match user-input string $kwd.

function delnote () {
   read kwd
   sed -e "/$kwd/d" -i ~/notes.txt
}

Instead, I keep getting “sed -e expression #1, char 0: no previous regular expression” errors. Why?

I’m new to both bash and sed (and MSYS), so I’m not sure whether this is an issue of passing variables to sed or using quotes the wrong way (I’ve effortlessly tried replacing "" with '' in many variations). I tried using the function provided here instead of my own, but still got the same error.

In case this is an issue of misplacing quotes, then what’s the difference between how sed and grep handle user input in bash? (As opposed to sed, using '"$*"' in a grep function does work.)

Thanks for any help and explanations!

  • 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-04T11:13:18+00:00Added an answer on June 4, 2026 at 11:13 am

    Okay, I yet seemed to mess something up when copying the solution linked above. Now it works, like this:

    function delnote () {
      sed -e "/`echo $*`/d" -i ~/notes.txt;
    }
    

    As a non-coder and n00b, I’d still appreciate any explanations as to what was wrong with my initial version, though. Plus, why does echo seem to fix the issue here? Thanks.

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

Sidebar

Related Questions

I need to combine lines in two files, basing in the condition, that in
I've got a Windows batch script issue that I'm bashing my head against (no
I have been bashing my head against a wall all morning trying to figure
We've been bashing our heads off of this one all morning. We've got some
Hey all, really bashing my head against a keyboard here, any information or pointing
The task I was trying to accomplish was that given an input pattern, e.g.
I didn't get an optimized regex that split me a String basing into the
I have been bashing my head against this for a while now and need
So right now I'm bashing my head - at the moment we use an
I often hear people bashing ORMs for being inflexible and a leaky abstraction, but

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.