Question

Shell script: Obtain IP Address of a Network Interface: User input interface Output should be: $...

Shell script:

Obtain IP Address of a Network Interface:
User input interface

Output should be:

$ ./admino -i en0
Your ip for en0 interface is:10.0.1.10

Homework Answers

Answer #1

Answer:

for iface in $(ifconfig | cut -d ' ' -f1| tr '\n' ' ')
do 
  addr=$(ip -o -4 addr list $iface | awk '{print $4}' | cut -d/ -f1)
  printf "Your ip for $iface interface is: $addr"
done

Output:

Please give thumbsup, or do comment in case of any query. Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
a) An IP address is a number that uniquely identifies a device within a computer network....
a) An IP address is a number that uniquely identifies a device within a computer network. This address can be derived from a General Network Address. i. Using any network address of your choice, explain how you would generate IP addresses by subnet masking. ii. Briefly explain the concept of Host Address and Network Address.
Your company has a policy to use the first IP address in a network as the...
Your company has a policy to use the first IP address in a network as the default gateway address. You have been instructed to configure a new server with an IP address of 192.168.184.227 and a subnet mask of 255.255.255.248. What is the network address for this network? What is the default gateway for this server? Reflection Why is the subnet mask important in determining the network address?
Given the IP address 172.16.45.0 and the mask 255.255.224.0, what is the corresponding network address? Show...
Given the IP address 172.16.45.0 and the mask 255.255.224.0, what is the corresponding network address? Show how you arrived at your answer.
You are configuring two PCs for your network. PC-A is given an IP address of 10.0.0.16,...
You are configuring two PCs for your network. PC-A is given an IP address of 10.0.0.16, and PC-B is given an IP address of 10.1.14.68. Both PCs receive a subnet mask of 255.254.0.0. What is the network address for PC-A? What is the network address for PC-B? Will these PCs be able to communicate directly with each other? What is the lowest address that can be given to PC-B that allows it to be on the same network as PC-A?
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items separated by a space. Read the list. Use a for loop to write (use echo) the items to a file called shopping_list. You should use >> to append the output to the file, so each time the script is run the list should get longer. After the for loop finishes, display (use cat) the contents of the shopping list with 1 item per line....
Write a PHP script that tests whether an e-mail address is input correctly. Verify that the...
Write a PHP script that tests whether an e-mail address is input correctly. Verify that the input begins with series of characters, followed by the @ character, another series of characters, a perod (.) and a final series of characters. Test your program, using both valid and invalid e-mail address. Please make sure it outputs valid or invalid address
You are the WAN engineer for Widgets International. Your company has just purchased the IP network...
You are the WAN engineer for Widgets International. Your company has just purchased the IP network range 201.144.32.0/24. Your company needs two networks with 48 hosts per network using this IP network range. How do you subnet this IP network? What is the subnet mask you should use? What network address would you use? How would you write this in CIDR notation? What are the usable networks and ranges that you can use to accomplish your company s directive?
Define a function called positivity generator. The function should take user input of a sentence, and...
Define a function called positivity generator. The function should take user input of a sentence, and find the first appearance of the substring 'not' and 'bad' from the user input. If 'not' appears before the 'bad', the function should replace the whole 'not'...'bad' substring with 'good'. Return the resulting string. Note your function should be able to handle user input with difference cases. Example: Input = 'The ice cream is not bad!' Output = 'The ice cream is good!" Input...
PC33 and PC55 are connected to two different network. A router RX is used to allow...
PC33 and PC55 are connected to two different network. A router RX is used to allow communication between hosts attached to the two networks. PC55 is connected to a local area network. What is the network ID for that network? For the network mentioned in (1), where should we assign the gateway address? (For each device, write its name and its port/interface based on the given diagram, no IOS command for this question). Select one of the devices mentioned in...
Given the following output, what is the script for it? Welcome to Shell scripting Your home...
Given the following output, what is the script for it? Welcome to Shell scripting Your home directory is /home/Amal You are located now in /home/Amal/testExam Your running kernel version is Linux rehab-virtual-machine 4.13.0-37-generic #42-16.04.1-ubentu SMP … etc please give the answer in linux
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT