CSCI 373 -- Quiz 2 open section

This quiz must be turned in by 8:30 pm! You may use your notes, books, etc, in working on this section. However, you must turn in the closed section before you consult any of these reference materials. Unless you can write really small, use your own paper for this part of the exam.

Problem 1

Write a shell script that takes a single command line argument, the name of a file, and then prints a message that states the number of lines in the file which contains digits. Here's a sample run of such a program:

% prob1 /.login
3 lines in /.login contain digits

Hint: The program "wc -l" will write to standout output the number of lines contained in standard input.

Problem 2

Same as Problem 1, but prompt for the file to be checked. Sample run:

% prob2
Enter a file to be processed:  /.login
3 lines in /.login contain digits

Problem 3

Write a shell script that prints "ok", if its first command line argument starts with the letter 'y'; and prints nothing, otherwise. Here are some sample runs:

% prob3 yabba dabba do
% prob3
% prob3 no way
% prob3 y

Problem 4

Write a shell script that prints an appropriate "warning message" if the current directory contains files named apples and oranges.

penrose% touch apples
penrose% prob4
penrose% touch oranges
penrose% prob4
Warning:  Mixing apples and oranges!