teaching machines

CS 330 Lecture 3 – Shell Scripting, Part 2

January 27, 2017 by . Filed under cs330, lectures, spring 2017.

Dear students,

We will continue to work with the shell, a world between worlds. A place full of dead mice. Let’s start with a reading review:

  1. What does it mean for a directory to be executable?
  2. Write a command to run program place, reading from file bets and appending its output to file log.
  3. What will file .. report?
  4. Your program webify generates a lot of HTML. Write a command to only show the img tags.

Now it’s time for a segment I like to call What Does This Do? We’ll spend a moment absorbing each code snippet, and then I’ll ask what they do and what would be a good name for the script.

Then we’ll write some scripts:

  1. Bookmark a directory for later return.
  2. Send files to limbo/recycling bin, rather than hell/non-existence.
  3. Send a mass email.
  4. Show the biggest files in a directory.
  5. Upload a local file to a web server and let the world see it.

Here’s your TODO list for next time:

Sincerely,

big

#!/bin/bash

du -s * | sort -nr | head

redir

#!/bin/bash

cd $(cat ~/.dirmark)

save

#!/bin/bash

pwd > ~/.dirmark