Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

bash echo is doing commands and not adding what I need

I need to create a new file name test.sh.
I need to write those lines with echo or somethings else but cant open new file manually and write it.
That is, I have to write down some things in the bash such a way that the following file is created:

TEST_VALUE=$1
if [[cat data | grep $TEST_VALUE]]; then
exit 1
fi
exit 0

But, when I do that by echo the result is:

TEST_VALUE=
if [[]]; then
    exit 1
fi
exit 0

I need the file as I write it with $1 and not the argument and with the grep.
I tried to grep each row but it is doing the command and not copied it as I want.
How do I do it?
Thank You

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

echo 'TEST_VALUE=$1 
if [[cat data | grep $TEST_VALUE]]; then
exit 1
fi
exit 0' > test.sh

You need to use quotes, in any other case your command will be executed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading