Here's what it's gonna look like.
Pretty cool, huh?
So let's get started
First we need to know how to interact with the terminal's standard input and output. It's easier than you think actually.
So the two commands we need are the following:
echo- for displaying text
read- for reading inputs
1. Create a file called
login.bash. And then copy
and paste the following code:
#!/bin/bash echo -n 'Enter your username: ' read -a username echo -n 'Enter your password: ' read -s password echo echo echo -e "Username: $username, Password: $password"
2. Hit save, and then run the script with the following command:
$ sign is to indicate that the above command is
done inside a terminal window.
echo -n outputs the quoted text into the terminal
without the new line
read -a username will activate the standard input promt
and will store the input value to the username placeholder.
-a flag will only store the first word and not
the whole line.
For password we use the
-s flag when reading the std
input to prevent the std out from printing the password.
And to get the value from a placeholder, prefix it with
So in our case, it's
That's about it.