0

what I am looking for is, use the output of one command as " EXACTLY THE OTHER COMMAND" in Linux ?

for ex:

[root@ip-10-0-0-136 ~]# echo hi
hi
[root@ip-10-0-0-136 ~]

now this "hi" I want to use as immediate command and execute. how can I do that ?

so, should be like :

[root@ip-10-0-0-136 ~]# echo hi
hi
[root@ip-10-0-0-136 ~]# hi

can it be possible ?

Please suggest

edit 1 :

please refer the specific example :

[root@ip-10-0-0-136 ~]# aws ecr get-login --no-include-email --region eu-central-1
docker login -u AWS -p eyJwYXlsb2FkIjoibWJ3aVJhNmpwbFkzVjhnVFA1SlFnTXhDWHZoYUlKaVJKVGxIQjdheVVOMkk0NzM5NHFKelVYOXUxN21EMmVRMkx4dmJickNOWDY3bFNjL2hMSWE3c0dDT2cyOWxXb25NUVEzZW1sL2szajlUYTc0cHBFVmhWVU1vSUJVdGVMcWhKZ3k3NkpjWGVWR283dkU4amVCWGo0eDdVU3ZUMUc4WE5xRXBKSlRyQlh6c2M0TnZMME9iR2lHa1BqeFUrS2wrc052clUyY3pLVW56bTZEZFNRSHFlckZFU1ZnMEFkTWV4bHluMzQxUDhzWFNpdDBzYm1zZDlIYUFnSUM0Q3A2a1FZQVlZL3NUYXN3Zk9BZytIbVpxaGY2NFdzdEYxajBsNmlnR2NnMEkzYmJ0czl5c3REb0VENnBtK0FqZ2lLN1hpUlNPL01raEt5bnRTZ1lGSnB3cjJxb0RTZDdkUWE1QUtoaFhQdy9MU3kzMlZUVDRyRCsyTVU5TXRKY2FWMjBINFJKcnN3c08yUWFJaHE4VGsrZGZlcUxaSHowb1RNZmxlaDYxbDV0emN1bkNBOHdKeDIxcEliaXlQbFR4dWVrczdzbW9hamEraThxUjFlMi9XUHhUbGdKd2g1Y2FEd1RhbitJdDBtNDZ1ckZuWjMxOXpWelgyUm9vMG0ycm5rUk1iYkhmT2dRS2RPSUs0V0tzQm91eDRic2o2bHJVeGk4dGFOdEgyNmdPUG1oRUlHaVJRMlRqTThQbFlDRDZ6dEZHc3F3NnRRbmVwZU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Bc28xcDFFbCt3PSIsInZlcnNpb24iOiIyIiwidHlwZSI6IkRBVEFfS0VZIiwiZXhwaXJhdGlvbiI6MTU0Nzc2OTEzNX0= https://890543041640.dkr.ecr.eu-central-1.amazonaws.com
[root@ip-10-0-0-136 ~]# !$
eu-central-1
bash: eu-central-1: command not found
[root@ip-10-0-0-136 ~]# $
bash: $: command not found
[root@ip-10-0-0-136 ~]#
2
  • 2
    what about $(echo hi)? Commented Jan 17, 2019 at 11:38
  • try $(aws ecr get-login --no-include-email --region eu-central-1) Commented Jan 17, 2019 at 12:03

4 Answers 4

3

You can use $(aws ecr get-login --no-include-email --region eu-central-1) This will execute the output of the command in the parenthesis. In your case the command docker login -u AWS -p eyJwYX.. will get executed

Refer: https://superuser.com/questions/935374/difference-between-and-in-shell-script

Sign up to request clarification or add additional context in comments.

Comments

2

You can use command substitution:

[root@ip-10-0-0-136 ~]# $(echo hi)

Which is identical to

[root@ip-10-0-0-136 ~]# `echo hi`

Comments

1

Yes, that is possible using !$. If I use [root@ip~ppp]$ echo cd cd [root@ip~ppp]$ !$ cd [root@ip~]$

Here cd command is executed

1 Comment

Thanks. I have modified my question with specific example . can you please check...
0

I think simply you can pipe some output and feed it to bash command.

echo 'ls' | bash

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.