How to change a command line argument in Bash?

前端 未结 3 1074
野性不改
野性不改 2020-12-02 10:55

Is there a way to change the command line arguments in a Bash script? For example, a Bash script is invoked like this:

./foo arg1 arg2  

Is t

3条回答
  •  醉酒成梦
    2020-12-02 11:27

    Optimising for legibility and maintainability, you may be better off assigning $1 and $2 to more meaningful variables (I don't know, input_filename = $1 and output_filename = $2 or something) and then overwriting one of those variables (input_filename = 'chintz'), leaving the input to the script unchanged, in case it is needed elsewhere.

提交回复
热议问题