Question: 5 . Now we will write a shell script to display IP address of a specified interface. You know ifconfig command. Run it and check
Now we will write a shell script to display IP address of a specified interface. You know ifconfig command. Run it and check the results.
What if you'd like to see only IP addresses? You can modify your command as
ifconfig grep 'inet
grep is a commandline utility for searching plaintext data sets for lines matching a regular expression. This line means run ifconfig and return only line that starts with inet addr
You can add interface name to ifconfig as
ifconfig eth grep 'inet
Now we will create a script that display IP address of a specified interface. Create new file lIPscript.
echo "Choose interface eth wlan lo
read e INTERFACE
echo "You chose $INTERFACE"
The first line will display input prompt, the second one accepts your input, then your input is displayed.
Run your code and provide eth as input. If you see You chose eth then you are ready for the next step. Provide a screenshot of your code run. point
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
