小编dba*_*min的帖子

如何将 read -s 与 printf 一起使用

如果我使用“read -s”,它将删除现有行并将下一个提示带到同一行,如下所述。请让我知道此错误的任何解决方案。我需要使用“-s”来读取而不是在屏幕上回显密码。

脚本:


$ cat a.sh
printf "Enter the db name : "
read -r sourcedb
printf "Enter the source db username: "
read -r sourceuser
printf "Enter the source database password: "
read -s sourcepwd;
printf "Enter the target database username: "
read -r targetuser
Run Code Online (Sandbox Code Playgroud)

电流输出:


$ ./a.sh
Enter the db name : ora
Enter the db username: system
Enter the db password: Enter the target database username:
Run Code Online (Sandbox Code Playgroud)

期望的输出:


$ ./a.sh
Enter the db name : ora
Enter the …
Run Code Online (Sandbox Code Playgroud)

shell-script printf read

2
推荐指数
1
解决办法
247
查看次数

标签 统计

printf ×1

read ×1

shell-script ×1