Pass parameters that contain whitespaces via shell variable

后端 未结 4 1238
南方客
南方客 2021-01-23 12:30

I\'ve got a program that I want to call by passing parameters from a shell variable. Throughout this question, I am going to assume that it is given by

#!/bin/sh         


        
4条回答
  •  误落风尘
    2021-01-23 13:26

    Use an array to store multiple, space-containing arguments.

    $ args=("first one" "second one")
    $ count-args "${args[@]}"
    2
    

提交回复
热议问题