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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:07:16+00:00 2026-05-12T06:07:16+00:00

What I would like to do is something like the following: #!/bin/sh EMAIL=-e ‘s/SOMETHING//g’

  • 0

What I would like to do is something like the following:

#!/bin/sh
EMAIL="-e 's/SOMETHING//g'"

somecommand | sed "$EMAIL"

But I get the following:

sed: -e expression #1, char 2: unknown command: `''

I’ve tried many variations. I know it just a matter of getting the string quoting right. The reason I’d like to do this is to break a long sed command up for readability. Should I just use a sed script-file (with the -f option) instead?

UPDATE:

My actual script is a little more complex:

#!/bin/sh
EMAIL="-e s/SOME THING//g -e s/SOME THING ELSE//g ..."

somecommand | sed "$EMAIL"

After removing the single quotes I get:

sed: -e expression #1, char 18: unknown option to `s'
  • 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-12T06:07:17+00:00Added an answer on May 12, 2026 at 6:07 am

    For this type of quoting problem, you could do one of:

    #!/bin/sh
    SED_ARG="-e 's/SOMETHING//g'"
    echo SOMETHING | eval sed "$SED_ARG"
    echo SOMETHING | sed $SED_ARG
    

    What’s happening is that in your version, the shell is invoking sed with one argument (the string “-e ‘s/SOMETHING//g'”), but you want sed to be invoked with two arguments (“-e” and “‘s/SOMETHING//g'”). Eval causes the shell to interpret the string the way you want, as does not quoting the argument so that word splitting occurs. Note that this sort of thing is pretty fragile.

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

Sidebar

Related Questions

I would like to do something like the following but can't seem to get
I would like to do something like the following with spark. <viewdata model=IList[[string]] />
I would like to use something like the following: SELECT city FROM cities WHERE
I would like to do something like the following: if params[:entry].include? (http || www
Would it be possible to do something like the following in c#? Basically TParent
I have a file template.txt which contains the following: Hello ${something} I would like
I would like something like the following. I want just an utility that is
I would like to run something like: select * from table where field in
I would like do something like that. list_of_urls = ['http://www.google.fr/', 'http://www.google.fr/', 'http://www.google.cn/', 'http://www.google.com/', 'http://www.google.fr/',
I would like to do something like this i.e., use wild card characters in

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.