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

  • Home
  • SEARCH
  • 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 3672344
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:35:49+00:00 2026-05-19T02:35:49+00:00

I set up a variable in the shell: -bash-3.00$ echo $source_repl source ../setup_simple.tcl I

  • 0

I set up a variable in the shell:

-bash-3.00$ echo $source_repl
source ../setup_simple.tcl

I then tried to replace a line in a file that started with the string “package require IxLoad” with the variable string (noting that double quotes are the way to get sed to use variable substitution). First I tried with direct substitution (no escaping the $ in the variable):

-bash-3.00$ sed -e "s/package require IxLoad.*/$source_repl/g" smtp_tput191Mb.tcl > tmpwatch.tcl
sed: -e expression #1, char 38: unknown option to `s'
-bash-3.00$

So I thought that escaping the $ would solve the problem but as you can see the line is then replaces by the literal string “$source_repl” rather than the variable stored there:

-bash-3.00$ sed -e "s/package require IxLoad.*/\$source_repl/g" smtp_tput191Mb.tcl > tmpwatch.tcl
-bash-3.00$ diff smtp_tput191Mb.tcl tmpwatch.tcl
11c11
< package require IxLoad
---
> $source_repl
-bash-3.00$ 

I looked up many sites on how to do variable substitution in sed and they all seem to indicate that the above should work. What am I missing? Is there something in the actual variable that’s causing this?

A

  • 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-19T02:35:50+00:00Added an answer on May 19, 2026 at 2:35 am

    Sorry for wasting your time folks. I found the problem. I needed to escape the dots and slashes in the actual variable in order to replace it with the sed statement:

    -bash-3.00$ echo $source_repl
    source \.\.\/setup_simple\.tcl
    -bash-3.00$ sed -e "s/package require IxLoad.*/$source_repl/g" smtp_tput191Mb.tcl > tmpwatch.tcl
    -bash-3.00$ diff smtp_tput191Mb.tcl tmpwatch.tcl                                          11c11
    < package require IxLoad
    ---
    > source ../setup_simple.tcl
    -bash-3.00$
    

    Thanks

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

Sidebar

Related Questions

I need to set a system environment variable from a Bash script that would
I'm working on a web application that will return a variable set of modules
Have a shell script that reads the files in a particular directory. #!/bin/bash for
What startup scripts—in the order that they are called—set the PATH variable when opening
I have an env var that's being set(PYTHONPATH) whenever I open a new Bash
Is it possible to retrieve variable set in onreadystatechange function from outside the function?
I am trying to set a ViewState-variable when a button is pressed, but it
I need to set an environment variable in Python and find the address in
When I try to set the z variable in the code below, I get
In Visual Studio 2003, I am trying to set an environment variable in the

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.