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.
使用 bash 脚本,如何将信息保存在文件中,而不在控制台上打印?我编写了一个脚本,要求用户输入一个值。该值必须记录在文本文件中,而不是在屏幕上打印。到目前为止,我已经写过:
echo "x = " read v_x echo $v_x > temp.txt
但这会将其打印在屏幕上并将其保存在文件中。
您可以使用-s读取选项:
-s
read -s v_x
help read告诉:
help read
-s do not echo input coming from a terminal