问题描述
我刚开始编写bash文件以打开虚拟命令提示符。我一直在尝试打印用户名,当前日期以及当前在我的计算机上运行进程的所有用户的列表。我一直在使用记事本++。错误发生在
whoami="$users"
echo 'Good day to you,' "{$users}"
通过打印{ }
并使用
echo 'These are a list of users who are currently running processors on this computer: '
echo "{$ps}"
这也会打印{ }
。我该怎么做才能使它们正确打印?
解决方法
您可以尝试这样。
#Set current user
user=$(whoami);
echo 'Good day to you,' $user
#Set Date
current_date=$(date);
echo 'Today is,' $current_date
echo 'These are a list of users who are currently running processes on this computer'
echo $(ps -A)