Linux at Rancho Santiago College

Linux is being used to teach Computer Science classes at a community college in Santa Ana, California.
Electronic Blackboard

I have taught Unix and networking seminars and training sessions nationwide. There is one teaching technique I use in these sessions and also in my classroom that I am asked about most frequently. I call it my “electronic blackboard”. It allows me to broadcast everything that appears on my station to all Unix stations in the room. Students can watch me enter commands, backspace, make corrections and use command-line editing to develop long, complicated pipe sequences in gradual steps. Instead of writing on a blackboard, I use vi to put any notes into a file. Students see the notes as I type them, as well as how I use vi, and at the end of class I can print the file as a handout. (It helps that I am a speedy typist.)

This broadcasting technique is scalable in that I can broadcast to one station as easily as to 200 or 500 stations. I can do this broadcasting using two simple Unix commands that are available on all flavors of Unix including Linux. No special software is required. Can you figure out how I do it? Here is the answer. At my station, I first run this command:

telnet localhost | tee /ttt

This gives me a new Unix login. All output and the echo of everything I type will now be saved in the file /ttt. (If you don't have networking set up, you can do the same thing using cu, or call up, and a loop-back cable between two serial ports.)

At each of the student stations, run this command:

tail -f /ttt

tail will run until aborted, reading every new keystroke added to file /ttt and displaying it on each student's screen. Now each screen perfectly reproduces what appears on my screen. I can also automate this by writing a script to start all the tail<\!s>-f commands at one time. Note: each student station must be set up to use the same TERM variable as I am using at my teaching station, since escape sequences and graphics will also be broadcast.

Advanced Regular Expression Lesson

In closing, I would like to leave you with a lesson that I teach in advanced regular expressions, which applies to Linux as well as other flavors of Unix. The rule is: “to simplify line-oriented regular expressions, drop unbounded or more wild cards.” This is analogous to simplifying unnecessarily complex fractions in mathematics. The simplified expression is more efficient to implement and easier to understand. I find that most students understand advanced regular expressions much better once they understand this rule.

In regular expressions there are two wild cards that I call “or more” wild cards, as shown in these two examples:

grep  'aa*bc'  file

Search for and display any lines in file that contain one or more instances of a's, then b, then c.

grep -E 'abc\{10,\}' file
Search for and display any lines in file which contain a, then b, then 10 or more instances of c.

Both of these “or more” wild cards are unbounded, because the “or more” wild card occurs either at the start or the end of the regular expression pattern.

Contains “or more”

Better Pattern

1. aa*bc


2. abc\{10,\}


3. zaa*bc

zaa*bc (same)

4. abc\{10,\}$

abc\{10,\}$ (same)

In example #1 above, the “or more” wild card is unbounded, so leave it out. Searching for abc is more efficient and easier to understand than searching for aa*bc and results in the same lines being selected.

In example #2 above, the “or more” wild card is again unbounded, so leave out the comma. To prove that two regular expression patterns are equivalent, we need to show:

  1. They do select the same lines. In this case, any line that contains a then b then 10 or more c's also contains a then b then 10 c's.

  2. They avoid the same lines. In this case, any line that does not contain a then b then 10 or more c's also does not contain a then b then 10 c's.

In example #3 above, the “or more” is bounded on both sides, so you cannot ignore it. Looking for z, then one or more a's then b then c is different than looking for z then a then b then c.

In example #4 above, the “or more” is bounded on both sides, so you cannot ignore it. The $ sign indicates the 10 or more c's must occur at the end of the line, which is different than looking for exactly 10 c's at the end of the line.

The sed command is not line-oriented, hence this rule does not apply.

sed s/aa*bc//g file

This command instructs sed to delete any segment in file that consists of one or more a's, then b, then c.

Command to delete any segment which consists of a then b then c:

sed s/abc//g file

Since sed is not line oriented, do not drop unbounded “or more” wild cards.

Steve “Mor” Moritsugu ( is a senior software engineer at DTR Business Systems in Walnut, California. He is also the Unix instructor at Rancho Santiago College in Santa Ana, California.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks for the info... Linux

rico45's picture

Thanks for the info... Linux Rocks!!!

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up and watch now

Sponsored by Skybot