Kaveen M.
Kaveen M.

Reputation: 145

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

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

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

Upvotes: 0

Views: 181

Answers (1)

Sebastiano Grassi
Sebastiano Grassi

Reputation: 63

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

Upvotes: 1

Related Questions