【问题标题】:How do I add a new username and password to a database list (i have a pass file an a username file如何将新的用户名和密码添加到数据库列表(我有一个通行证文件和一个用户名文件
【发布时间】:2017-04-14 14:49:23
【问题描述】:

!/bin/bash

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

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

我已经尝试了我能想到的一切,如果你能帮助我,我会喜欢的。 谢谢你, 扎克

【问题讨论】:

    标签: linux bash passwords


    【解决方案1】:

    要将屏幕的输出重定向到文件,可以使用>>>进行追加,例如

     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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-18
      • 2021-12-22
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多