Starting with Some Small Stuff Administrivia * I've had a request to move this to Tuesdays. * Staying on Mondays. Review * What did we learn last week? * Something good to know: Redirecting stderr to stdout * Automate for efficiency * If you're doing something once, by hand may work * If you're doing something multiple times, writing a helper amortizes * tr is a useful tool for doing character-based replacement or deletion * Generalize: You may not need to write programs; tools may already be there, so learn the tools * od is also a useful tool Simple *nix Tasks, Continued * Given a CSV in which each line has LastName,FirstName,Assignment,NumericGrade find the lines with the five highest grades on homework 2. * Observation: * Need a way to identify the grade part * Need to know how the programmer identified hw2 ("hw2") * Strategy: Identify subtasks * extract only the lines that have hw2 (however it is represented) grep ",hw2," grades # Hidden assumption: No one has a name or numeric grade of "hw2" * sort lines by grade sort -t, -k4 -g -r * get the first five lines head -5 * So, pipe them all together cat grades.txt | grep ",hw2," | sort -t, -k4 -g -r | head -1 * Not only do we need to know tools, we need to be willing to combine them. * Getting close to write-only code. * Given an HTML file, find the URLs of all images. * Assumptions: no more than one image per line, complete tag per line * Identify subtasks * Find the image tags in the file using grep cat file.html | grep -i "