小编Mel*_*son的帖子

如何插入作为参数发送的字符串?

我对文件系统的访问权限有限,并且我想设置通用通知处理程序调用,如下所示:

notificator.sh "apples" "oranges" "There were $(1) and $(2) in the basket"
Run Code Online (Sandbox Code Playgroud)

notificator.sh内容:

#!/bin/sh
echo $3
Run Code Online (Sandbox Code Playgroud)

并得到如下输出:

"There were apples and oranges in the basket"
Run Code Online (Sandbox Code Playgroud)

这可能吗?如何实现?我更喜欢它是一个内置的 sh 解决方案。我实际上正在尝试通过curl post param将结果字符串($3)作为消息发送给电报机器人,但试图简化情况。

shell string-interpolation command-line-arguments

5
推荐指数
1
解决办法
2437
查看次数