Homework 1, Capture the File.
Short Description:
Copy files from your instructor's directory, modify these files, submit the results.
This assignment is worth 5 points.
Goals
When you finish this homework, you should:
- Have copied a several files from your instructor's directory
- Compiled a program on the linuix system.
- Sent email to your instructor with attached results.
The main goal of this assignment is to get you back working in the linux environment, with all of the tools needed to do your homework. If you experience any difficulties, or need further assistance, PLEASE ASK.
Formal Description
The directory ~dbennett/230/hw1 contains a solution to a simple assignment.
Assignment 0: Do some stats.
The user has a number of files containing either integer or floating point data. The user would like to perform statistics on these files, but would like to do so in batch.
The program should read a file called files.in, which contains the names of all of data files, one per line. For each file name, open and process the associated data file.
Each data file will contain meta-data describing how to process the file. This meta-data consists of a string, either integer or real. This is followed by an integer representing the number of spaces for output, and in the case of real, it is also followed by an integer giving the precision for output. Immediately following the meta-data is the data, a series of number of the type named by the string.
Your program should read in the numeric data, and print it back out using the specified width and precision. It should also count the number of input data values and compute the sum and the average of these input values, which it should also print.
You may assume valid data with no errors.
Your task is threefold.
- Copy these files to your directory
- Modify both the code and the data files.
- Submit your work via email to your instructor as a tar file.
Copying Files
Throughout the semester I will write code which I will make available in my directory on the CS domain. You need to be able to access and copy these files. Part of the purpose of this assignment is to make sure that you can copy files.
Copy the files from ~dbennett/230/hw1 into your directory structure so that you may modify them. You should place these files in a new sub directory.
- The source directory is ~dbennett/230/hw1. There are five files in this directory,
- main.C: the source code.
- files.in: the list of input files.
- a.dat: an example of integer input.
- b.dat: an example of floating point input.
- Makefile: we will discuss these later, but once you copy thes files into your directory, this will allow you to build the program by typing make.
- You can list these files by typing
ls ~dbennett/230/hw1
- You can copy a.dat to your current directory by typing
cp ~dbennett/230/hw1/a.dat .
Note that command ends in a . which you must type.
- You can copy the entire directory to your directory by typing
cp -r ~dbennett/230/hw1 .
This will create a new directory called hw1 in your current directory
- There are other possibilities, if you want to do something different just ask.
Modifying Files
A second purpose of this assignment is to make sure you can perform all steps of the edit-compile-execute cycle. Remember, a text editor can manipulate code or data files.
Submitting Files
There are several ways to do this, but I would like you to use the TAR program.
To create a TAR file of the directory hw1
- Remove all executables and object files from the directory containing the files you wish to submit.
- Move to the directory above the directory you wish to submit.
- tar cvzf hw1.tgz hw1
- The order is important.
- tar is the command.
- cvzf are actions
- c means to create a tape archive
- v means to be verbose, ie show you what it is doing
- z means to compress the file with gzip
- f means to output to a file, not stdout.
- hw1.tgz is the output file, it will be created
- hw1 is the input file, it is what will be compressed.
Required Files
The modified files compressed into a tar file.
Submission
Email your tar file as an attachment to dbennett@edinboro.edu. Make sure that the title indicates that this is homework1 and that your name and section are included in the body of the message.