SESSION 4		SIMPLE UNIX UTILITIES


1. ls

The command `ls' lists the contents of the current directory in alphabetical 
order.  At present you have no files and so nothing will be shown. It is a 
feature of UNIX that performance of a command does not necessarily yield 
visible output. Do not be disconcerted by this.


2. date

This gives the day, date, time, year. Try it.


3. cal		(calendar)

cal 3 1946 		this prints the days/dates for the month March 1946.
cal 1946		this prints the days/dates for all of 1946

Question? On what day of the week were you born?

Try September 1752!


4. Standard input and output devices.

The keyboard is your standard input device (stdin) and the screen your standard 
output device (stdout). If you wish input to come from a different source or 
go to a different destination, you must explicitly specify this.

You may redirect the output from a command to a file (rather than to the
screen) by using the  >  key. The syntax is

		command > filename

This redirects the output of the particular command to the file whose name
you specify.

e.g. 	date > datefile

Type `ls' to list your files and confirm that the file exists.

Type
	cal 3 1946 > birthday

Type `ls' to confirm the existence of the file. You should now have two files.

Similarly  <  can be used to input data TO a command FROM a specified file e.g. 

	mail hcb1 < homework

which sends the file `homework' to the user `hcb1'.


5. rm   filename

This command deletes (removes) the file specified. Be careful in its use!

   rm -i  filename

This is a safer option to use. The -i option tells the command to ask for
confirmation, y for yes and n for no, before deletion is carried out.


6. cat		(concatenate)

a) cat file1			this prints the contents of the file called 
 				file1 to the screen.

b) cat datefile birthday	this prints both files in order specified
				(i.e. concatenates) to the screen.

c) cat datefile birthday > datbirth
				this concatenates the two files and puts
				the output in the new file called datbirth.
				Output is not displayed on the screen.

d) cat can also be used to create files (usually only very simple ones - we 
will normally use `notepad' (from the `Applications' directory) to create 
and edit files).

Type
		cat > hithere

The cursor will move to the next line where you may now type your message.
Type three lines. Then press return to move to an empty line and finally 
type
		ctrl d

You will be returned to the shell prompt. Type `ls' to confirm that the new 
file exists. Then type `cat' to display the file. 



7. It is a good idea to use filenames which are descriptive of their contents!


8. Remember that UNIX is case sensitive!!


9. UNIX Command Summary

ctrl c		interrupts a command
who		see who is logged on
who am i	login id and tty of yourself
passwd		assign or change password
ls		lists files in current directory
date		gives day, date, time, year
cal		calendar
>		redirects output to specified file
<		inputs data from a specified file
rm		deletes specified file
rm -i		deletes specified file after confirmation
cat		displays, joins, creates files


10. Exercises:

	a) Create a file using `cat' with 4 short lines of text.
	b) Read your existing files using `cat'.
	c) Combine 2 of your files and store them in a new file.
	d) Examine your directory of files using `ls'.
	e) Delete one of your files using `rm -i'.



END OF SESSION 4				file: utilities4
