我创建了一个名为usernum的永久别名,如下所示:

usernum='who | wc -l'

它只返回有多少用户。
我试图将以下命令放入cronjob中。
echo "The following number of users are logged in: $usernum"

然而,这只是回声:
The following number of users are logged in:

如何使命令可以在带有替换的echo命令的字符串中使用?

最佳答案

更改为:

alias usernum='who | wc -l'
echo "The following number of users are logged in: $(usernum)"
The following number of users are logged in: 1

10-02 17:58