Unix Tools for Sequential Processing


The most common file structure that occurs in Unix is an ASCII file with the new-line character as the record delimiter and, when possible, white space as the field delimiter. Unix provides a rich array of tools for working with files in this form.

grep, a Unix took, searches the named input file for lines containing a match to the given pattern. /bin/csh is shell command interpreter with a C-like syntax. The first command-line argument $1 is the URL and the second argument $2 is the ISBN, the pattern.

~wenchen/public_html/cgi-bin/351/week6/Sequential.sh

#!/bin/csh
echo  " ";    echo " ";
lynx  -dump  -source  $1  >  input.txt
echo  "<center><br><br><h3><font color='navy'>"
grep  $2  input.txt
echo  "</font></h3></center>"


Direct Access


Direct accesses are in contrast with sequential accesses. Whereas sequential searching is an O(n) operation, direct access is O(1). No matter how large the file is, we can still get to the record we want with a single seek. The major problem with direct access is knowing where the beginning of the required record is.

Direct access is the optimal access but is also hard to achieve. Much of the remainder of this text is devoted to identifying better ways to access individual records.