Variables on bash
FirstName=Pedro
SecondName=González
echo $FirstName $SecondName
Pedro González
user=$(whoami)
Bash scripts must start with #!/bin/bash header
Arguments
cat arg.sh
#!/bin/bash
echo "The first two arguments are $1 and $2"
./arg.sh hello there
The first two arguments are hello and there
Reading User Input
cat input.sh
#!/bin/bash
echo "Hello there, would you like to learn how to hack: Y/N?"
read answer
echo "Your answer was $answer"
./input.sh
Hello there, would you like to learn how to hack: Y/N?
Y
Your answer was Y
cat input2.sh
#!/bin/bash
# Prompt the user for credentials
read -p 'Username: ' username
read -sp 'Password: ' password
echo "Thanks, your creds are as follows: " $username " and " $password
./input.sh
Username: kali
Password:
Thanks, your creds are as follows: kali and nothing2see!