[英]write a shell script to display count of users currently logged in and write the count in "count.txt". Display the count.txt file content
Display count of users currently logged in and write the count in
count.txt
.显示当前登录的用户数并将计数写入count.txt
。 Display thecount.txt
file content.显示count.txt
文件内容。
I used this but it's not giving the right answer.我用过这个,但它没有给出正确的答案。
ls -l | wc > count.txt
cat count.txt
As said by @Barmar ls -l
is not a correct command to have the number of users logged in.正如@Barmar 所说, ls -l
不是让登录用户数量正确的命令。
Try w command.尝试w命令。 So thi muse looks like this:所以 thi muse 看起来像这样:
w -h| wc > count.txt
cat count.txt
The -h argument is to remove headers line. -h参数是删除标题行。
who | wc -l > count.txt;
cat count.txt
This will work -这将工作 -
who |谁 | wc> count.txt wc> 计数.txt
cat count.txt猫数.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.