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?



 


f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,306
Reaction score
3,924
Credits
38,697
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top