SD 212 Spring 2024 / Homeworks


hw13: Eagles csvs

  • Due before the beginning of class on Wednesday, February 7

Your task

Write a bash script eagles.sh that displays the header lines of any csv files that mention an eagle.

Specifically, your eagles.sh script should look at any files in the current directory whose filename ends in .csv, and if any such file has the string “eagle” in it anywhere (case insensitive), display a line containing the filename, a colon, and then the first line of that file.

For example, if your directory contains the three example files birds.csv, babies.csv, and superbowl.csv, then running your program should result in:

roche@ubuntu$ bash eagles.sh
birds.csv: EnglishName,Species,Lifespan
superbowl.csv: Date,SB,Winner,Winner Pts,Loser,Loser Pts,MVP,Stadium,City,State

Hints:

  • Try to use a for loop with an if statement inside the loop.
  • You might want to review this previous HW
  • Remember your bash commands and use them well! Look over this list if you need to remember which ones we learned about.

Submit command

To submit files for this homework, run one of these commands:

submit -c=sd212 -p=hw13 eagles.sh
club -csd212 -phw13 eagles.sh