[英]I would like to add 2 random numbers on the end of each username created from a file. How would I do this in bash?
[英]How do I add a new username and password to a database list (i have a pass file an a username file
我正在為我的linux課程學習一些東西。 我正在嘗試制作一個腳本,用於記錄您的用戶名並將其發送給“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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.