Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass variable's values in multiline string shellscript

Tags:

bash

shell

ubuntu

I have a variable called instdir that has the current directory. I need to pass its value to a multiline string that will be written to a file. As instdir finishes with a slash I can't do anything like this:

cat > test <<EOF
  $instdir/final/path/to/file
EOF

But If I use $instdirfinal instead, it won't recognize the real instdir's value. What I suppose to do?

like image 666
waldyr.ar Avatar asked Sep 21 '26 10:09

waldyr.ar


1 Answers

Here's the trick:

${instdir}final
like image 162
Vaughn Cato Avatar answered Sep 23 '26 02:09

Vaughn Cato



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!