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

Execute a Response of a command in bash

In the following script the response of sed is

export SECRET_KEY= '321321

I need to execute that response in the shell, exporting the value to SECRET_KEY i.e. echo $SECRET_KEY will give the exported key as 321321

aws-runas test >>test.txt
echo `sed -n -e 's/^.*\(\(export SECRET_KEY\).*\)/\1/p' test.txt`

I’ve tried using eval, source <(echo $command). it gives the following error

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

sed: -e expression #1, char 13: unterminated `s’ command

Is there a way to execute the response of sed as a command?

>Solution :

You can just use sed:

`sed -n -e 's/^.*\(\(export SECRET_KEY\).*\)/\1/p' test.txt`

Be careful, the export that you made doesn’t work.

export SECRET_KEY= '321321'
export: not an identifier: 321321

Use:

export SECRET_KEY=321321
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