Home > Software engineering >  Execute a Response of a command in bash
Execute a Response of a command in bash

Time:02-14

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?

CodePudding user response:

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
  • Related