linux - 如何将新的用户名和密码添加到数据库列表(我有一个密码文件和一个用户名文件

标签 linux bash passwords

!/bin/庆典

我正在为学校的 Linux 类(class)做一些事情。我正在尝试制作一个脚本来记录您的用户名并将其发送给“users2”。还有将转到“passwords2”的密码。

echo -n "username:" read | user2
echo -n "password:" read | password2

我已经尝试了所有我能想到的方法,如果你能帮助我,我会很乐意的。 谢谢你, 扎克

最佳答案

要将输出从屏幕重定向到文件,您可以使用 >>>> 附加,例如

 echo "Some text" > file.txt
 echo "Some other text" >> file.txt

将导致

$ cat file.txt 
Some text
Some other text

要将用户输入存储到变量中,比如 input,请使用 read input

除此之外,您在 echo ...read 这两个命令之间缺少分号(或将它们放在不同的行中)。

脚本的最小示例,将用户输入附加到文件:

#!/bin/bash
echo -n "Input: "; read input
echo $input >> file.txt

关于linux - 如何将新的用户名和密码添加到数据库列表(我有一个密码文件和一个用户名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43413908/

相关文章:

linux - 是否可以在 Linux (Ubuntu 16.04.1 LTS) 上安装 JBoss Fuse 6.3?

意外标记附近的 Python 语法错误

linux - 如何从给定事件中删除匹配模式

bash - 如何在 not_if 条件下使用 shell 脚本

linux - 在 LAMP 环境中从 XHTML 生成 PDF

bash - pg_backup.sh : "No such file or directory" for pg_backup. 配置

python - 调用需要来自 bash for 循环内的输入的 python 脚本

php - 如何防止更新表单上密码字段的双重 md5?

perl - Perl 如何在不显示终端的情况下提示输入密码?

Android - 密码保护设备管理员禁用