Skip to main content
deleted 22 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

I need to set a value of JavaScript variable from bash. Variable lives in index.html file and I'd like to use unix SED command to do that. Inside index.html I have it lake this:

<script>
/*bash_var*/ var foo = 1;  /*end_bash_var*/
</script>

I tried to do it like this:

sed -i -e 's%/*bash_var*/(.*)/*end_bash_var*//'"$ var foo = 0; /g" index.html

and few more variations of this command, but I alway get some error.

Thanks for any help.

I need to set a value of JavaScript variable from bash. Variable lives in index.html file and I'd like to use unix SED command to do that. Inside index.html I have it lake this:

<script>
/*bash_var*/ var foo = 1;  /*end_bash_var*/
</script>

I tried to do it like this:

sed -i -e 's%/*bash_var*/(.*)/*end_bash_var*//'"$ var foo = 0; /g" index.html

and few more variations of this command, but I alway get some error.

Thanks for any help.

I need to set a value of JavaScript variable from bash. Variable lives in index.html file and I'd like to use unix SED command to do that. Inside index.html I have it lake this:

<script>
/*bash_var*/ var foo = 1;  /*end_bash_var*/
</script>

I tried to do it like this:

sed -i -e 's%/*bash_var*/(.*)/*end_bash_var*//'"$ var foo = 0; /g" index.html

and few more variations of this command, but I alway get some error.

Source Link
Ladislav M
  • 123
  • 1
  • 3

Replacing code between two JavaScript comments

I need to set a value of JavaScript variable from bash. Variable lives in index.html file and I'd like to use unix SED command to do that. Inside index.html I have it lake this:

<script>
/*bash_var*/ var foo = 1;  /*end_bash_var*/
</script>

I tried to do it like this:

sed -i -e 's%/*bash_var*/(.*)/*end_bash_var*//'"$ var foo = 0; /g" index.html

and few more variations of this command, but I alway get some error.

Thanks for any help.