0
format_url=$(echo $new_url | sed  "s#/#\\/#g")

The echo command is giving the desired output. But I am unable to capture the output in a variable. Please suggest.

Master
  • 19
  • 1
  • 3
    Change the double quotes to single quotes. – Casimir et Hippolyte Oct 22 '19 at 14:29
  • Possible duplicate of [Store output of sed into a variable](https://stackoverflow.com/questions/6749128/store-output-of-sed-into-a-variable) – Corentin Limier Oct 22 '19 at 15:21
  • Please add some context to help debugging. 1. What's the string you have, tell us the output of ``echo "$new_url"`` 2. What's the output you get from just ``"$new_url" | sed 's#/#\\/#g'`` 3. Use single quotes (see above comment), because you use special characters that you otherwise need to escape 4. Always put variable substitutions in "" 5. Have you gotten any error messages? Maybe your output is simply EMPTY which would explain why you think the assignment failed - when in fact it succeeded. – Cornelius Roemer Oct 22 '19 at 16:26
  • @CasimiretHippolyte.. Thank you..single quotes solved the problem – Master Oct 23 '19 at 05:28

0 Answers0