#!/bin/csh # CSC 271 Midterm Exam, Fall 1994, problem 3: # Write a shell script with two parameters, the first a file name and # the second a directory name (for extra credit, have the second # parameter default to the current directory if not specified). # Your script should execute an "ls" command on the specified # directory, putting the output into the specified file name in the # directory _above_ the specified one. (This example is for real: # I actually needed to do something like this last month.) Don't # worry about what to do if the user gives the wrong number of kind # of parameters. # # For example, if I typed "p3 outfile ~/install", it would execute # the command "ls ~/install" and put the output into the file # ~/outfile. # # Extra credit: write the script so it'll run, successfully and # without warning messages, regardless of whether the output file # already exists. if ( $#argv < 2 ) then set dir=. else set dir=$2 endif unset noclobber ls $dir >$dir/../$1