In: Computer Science
LINUX/UNIX
Create a script named favcolor.sh.
Take 2 parameters, 1. Username, 2. Favorite color.
Print any sentence on console using these 2 parameters.
Here I am explaining above question below,see below
We mainly focus on the script in UNIX/LINUX below.
I am taking two variables called username and favcolor below in script.
favcolor.sh
#!/bin/sh
username="Siva"
favcolor="Blue"
echo "$username likes $favcolor Color"
To execute above script , you need to type bash favcolor.sh
Output : Siva likes Blue Color
The above one is one way.And we are going to take inputs from user console in another way..!!. see below
favcolor.sh
#!/bin/sh
echo "what is your user name:"
read username
echo "what is your fav color:"
read favcolor
echo "$username likes $favcolor Color"
To execute above script , you need to type bash favcolor.sh same as above one.
username is taken what you enter in the console.
username= "Username1"
favcolor is taken what you enter in the console.
favcolor= "favcolor1"
Output : Username1 likes favcolor1
Images:
Output:
Thank you..!!