Pattern expansion to run commands

前端 未结 2 682
说谎
说谎 2021-01-22 01:21

Knowing I am able to run echo or mv to expand patterns like these: echo {0..9}{A..Z}. I am curious to know if there is a way to do the sam

2条回答
  •  太阳男子
    2021-01-22 01:53

    You can use eval:

    eval docker-compose\ {stop,rm,'up -d'}\;
    

    Careful escaping/quoting is needed, though. Just test with echo instead of docker that it emits the correct commands:

    $ echo docker-compose\ {stop,rm,'up -d'}\;
    docker-compose stop; docker-compose rm; docker-compose up -d;
    

提交回复
热议问题