Lab in Linux/Unix Must download those two files References: Chapter 5 of Masteri
ID: 3821454 • Letter: L
Question
Lab in Linux/Unix Must download those two files References: Chapter 5 of Mastering Linux Bash Reference Manual objective: Become familiar with scripting features using options and the select menu. Commands: For the commands you need to use for this project, consult your textbook, the man pages, and the reference slides posted on moodle. Procedure: Download the following files from http://www.clarkson edul ee462: airlines cities 1. Script to select airline nights flights The two files, airlines and cities, have information about airline flights from selected cities to some destinations. Your script should determine the list of cities that are possible departures, and present a menu of possible city names: Please select the departure city: B Boston 4 Detroit 7) Las Vegas 10) San Francisco 8) Los Angeles Denver 5) 3) Chicago 9) Pittsburgh 6) Houston After the user selects a departure city, the script should display a similar menu of possible destinations. After selection of a destination, the script should display the list of all flights from the selected departure city to the selected destination. Your script should not hard-code any of the city names or airport codes, but should extract them from the files provided.Explanation / Answer
#!/bin/bash
file="cities.txt"
while IFS= read -r f1 f2 f3
do
printf '%s ' "$f2"
done <"$file"
printf '%s ' "Please select your departure city"
read depcityname
while IFS= read -r f1 f2 f3
do
if [ $f2 -eq $depcityname ]
then
depcode = $f1
if
done <"$file"
printf '%s ' "Please select your destination city"
read destcityname
while IFS= read -r f1 f2 f3
do
if [ $f2 -eq $destcityname ]
then
destcode = $f1
if
done <"$file"
file="airlines.txt"
while IFS= read -r f1 f2 f3 f4 f5 f6 f7
do
if [ $depcode -eq $f4 ] && [ $destcode -eq $f6 ]
printf '%s ' "$line"
done <"$file"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.