我正在编写一个Bash脚本,我需要在Bash脚本中传递一个包含空格的字符串到函数。
例如:
#!/bin/bash
myFunction
{
echo $1
echo $2
echo $3
}
myFunction "firstString" "second string with spaces" "thirdString"
当运行时,我期望的输出是:
firstString
second string with spaces
thirdString
然而,实际输出的是:
firstString
second
string
是否有一种方法可以将带有空格的字符串作为一个参数传递给Bash中的函数?