I am faceing an issue when I want to use variable inside cat <<EOF > Test.html , for example

cat <<EOF > Test.html <!DOCTYPE html> <head> <meta charset="utf-8"> <head> <style type="text/css"> */:root{--blue:#007 etc .. Then <!-- Heading --> <span> $Test </span> </div> etc .. EOF 

The $Test is not active I mean Bash considered it as a string not variable ( please find attached file )

variable $Test in brown color

1

1 Answer

You have to add escape as shown below:

cat <<\EOF > Test.html echo $var EOF 

Check the output by cat Test.html.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy