Is there a way to store long commands in an env variable?

dodo

New Member
Joined
Nov 12, 2022
Messages
1
Reaction score
0
Credits
12
I want to simply run the long command below.

Bash:
docker ps -a --format "table {{.Images}}\t{{.Ports}}"

Bash:
export view='docker ps -a --format "table {{.Images}}\t{{.Ports}}"'
echo $view

result
docker ps -a --format "table {{.Images}}\t{{.Ports}}"

But When I run the real variable, I get an error

Bash:
$view

Result end Error code

Bash:
"docker ps" accepts no argumets.
See 'docker ps --help'

Usage: docker ps [OPTIONS]

List containers


In short, can't save such long code as an environment variable?

and If possible, can I know another way?



 



Members online


Top