我一直在尝试将命令输出到这样的文件:
echo `who | cut -d' ' -f1 | sort | uniq` > users.txt
Run Code Online (Sandbox Code Playgroud)
但内容users.txt是在一条线上.
但是,如果我只是执行这样的命令:
who | cut -d' ' -f1 | sort | uniq
Run Code Online (Sandbox Code Playgroud)
输出在多行上.
如果我使用echo输出这样的命令:
echo `who | cut -d' ' -f1 | sort | uniq`
Run Code Online (Sandbox Code Playgroud)
我得到1行的输出.
这里发生了什么?如何将此命令的输出写入具有多行的文件?
任何帮助都非常感谢.
感谢一些评论,我意识到我不需要回声,我可以像这样输出:
who | cut -d' ' -f1 | sort | uniq > users.txt
Run Code Online (Sandbox Code Playgroud)