I am trying to set the following alias:
alias dash_token="echo $(kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}') -o json | jq -r ".data.token" | base64 -d)"
The problem is - when I run this command it executes the right side right away and assigns the result to the alias, instead of assigning the command. What am I doing wrong?
echo $(somecommand)instead of justsomecommand. – Gordon Davisson Aug 23 '21 at 02:17$(…)is expanded immediately. (2) An alias replaces text with text, it's not designed to do heavy lifting. (3) What is wrong withecho $(stuff)? – Kamil Maciorowski Aug 23 '21 at 04:31echo $(command)is that this alias/function is meant to just dump the acquired token to the console as a quick shortcut for users – Andrey Aug 24 '21 at 18:55echo $( )part, already does that. Output from the command goes to the terminal by default, so addingecho $( )doesn't do anything useful. – Gordon Davisson Aug 24 '21 at 19:12