Objective: To get experience using more advanced Unix commands
Due: Before class on Friday, Oct 17.
The goal is to answer the following questions using the least
amount of output. For example, if I were to ask you the number of
files in a directory, I don't want you to do
an ls
on the directory and then count the
number of files by hand. I want you to get the answer using piped
Unix commands, e.g., ls | wc
.
What is the Unix command that will answer each of the following questions?
System.out.print
but
not System.out.println
?
System.out.print
.)
public
will not show up in the
comments.After you have figured out the commands that answer the above
queries, demonstrate the commands using
the script
command.
The script
command records what you type in
a terminal into a file. By default, the file's name
is typescript
, or you can provide the name
of the file as a command-line argument, as in the example below. To
stop recording, type exit
Example use:
[sprenkle@hopper assignments]$ script cmd1.out Script started, file is cmd1.out [sprenkle@hopper assignments]$ pwd /home/faculty/sprenkle/public_html/cs209/assignments [sprenkle@hopper assignments]$ ls ./ assign1.php assign3.php assign7.html cmd1.out ../ Assign2.class assign4.html assign7.php header.php assign0.html assign2.html assign4.php assign8.html library.txt Assign0.java Assign2.java assign5.html assign8.php tmp/ assign0.php assign2.php assign5.php assign9.html assign1.html assign3.html assign6.html assign9.php Assign1.java Assign3.java assign6.php assign.css [sprenkle@hopper assignments]$ head assign9.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Assignment 9: Intermediate Unix Commands Practice</title> <link rel="stylesheet" type="text/css" href="assign.css" /> </head> <h1>Assignment 9: Intermediate Unix Commands Practice</h1> [sprenkle@hopper assignments]$ exit exit Script done, file is cmd1.out
The output file cmd1.out
looks something
like:
Script started on Mon 13 Oct 2008 05:14:57 PM EDT [sprenkle@hopper assign ments]$ pwd /home/faculty/sprenkle/public_html/cs209/assignments [sprenkle@hopper assignments]$ ls ./ assign1.php assign3.php assign7.html cmd1.out ... [sprenkle@hopper assignments]$ exit exit Script done on Mon 13 Oct 2008 05:15:20 PM EDT
In three separate files, demonstrate the Unix commands that answer the above questions. If you're using piping or commands within commands, execute the intermediate steps/commands before executing the whole command.
Copy your three scripts into an assign9
directory in your turnin
directory.
You will be evaluated based on the following criteria: