Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将 grep 结果显示到终端以及文件。我想出的解决方案是只运行两次,但这显然会产生效率问题。
grep -n "$SEARCH_TERM" "$i" grep -n "$SEARCH_TERM" "$i" >> /file.txt
是否有一个标签可以让它只使用一次搜索就可以打印到两者?
谢谢
您正在寻找的程序是“tee”:
grep -n "$SEARCH_TERM" "$i" | tee -a /file.txt