Sunday, June 5, 2022

[SOLVED] Shell Script - Echo inside Echo

Issue

So i'm trying to create a script1, this script has script2 data inside itself. what i'm trying is:

echo "echo"Hello"">>script2

it should show

(echo "Hello") inside script2 instead it is showing (echo Hello)

Please suggest what should i do to achieve it. Thanks.


Solution

You can escape the quote characters with \:

echo "echo\"Hello\"">>script2

Alternatively, use single quotes to ignore special characters inside the string:

echo 'echo"Hello"'>>script2


Answered By - kaylum
Answer Checked By - Senaida (WPSolving Volunteer)