SYS255 Lab 8 - Robertsegee/TechJournals GitHub Wiki

11/2/20 Lab 8 Bash: In this lab, we were introduced to basic bash scripting in Linux. While we have done related labs in the DHCP and WEB labs, this was the first time we got to mess around with scripts. Generally, I had a very easy time with this lab however, there was one part that took me a few days and lots of thinking to overcome. The problem in question was how to filter a nslookup output so that it only displays only lookups that are resolved. Initially, I thought that an if-statement would be could be used to easily filter out the unresolved IPs but I found no success in doing so as it would not filter the results. Eventually, after a few days of testing, I developed the idea that I could store the nslookup results in a separate text file. After doing so, I tested that they were stored in the file through the cat command. Then I used the sed command outside of the for loop to remove empty lines and lines containing the term "NXDOMAIN". This term means that the host was not able to be resolved, removing any lines containing it would therefore remove all unresolved hosts thus only leaving the resolved hosts. To make sure I could repeat this program without having to manually clear the text file with stored data, I used the ">" command at the end of the script to clear the file.