How to store a command in a variable in a shell script?

前端 未结 8 997
长情又很酷
长情又很酷 2020-11-22 07:35

I would like to store a command to use at a later period in a variable (not the output of the command, but the command itself)

I have a simple script as follows:

8条回答
  •  抹茶落季
    2020-11-22 08:16

    Be Careful registering an order with the: X=$(Command)

    This one is still executed Even before being called. To check and confirm this, you cand do:

    echo test;
    X=$(for ((c=0; c<=5; c++)); do
    sleep 2;
    done);
    echo note the 5 seconds elapsed
    

提交回复
热议问题