This tutorial session again takes the form of an interactive session. The tutorial includes the following:
Commence by using the ls, cd and more Unix commands to remind yourself of your directory structure and the files that you created last week. You should still have a directory called 2CS21 which contains at least the "myfile" and "timetable" text files you produced during the last tutorial.
Wild card characters provide a convenient short hand for specifying multiple file or directory names with one name. Two of the most useful wild card characters are * and ?. The * matches any string (sequence) of characters (including no characters), and the ? matches any one character. If you have not already done so "cd" to your 2CS21 directory. Now try the following:
$ ls myfile?
$ ls *
$ ls *.*
$ ls *.txt
$ ls myfile*
$ ls *file?
Wild card characters are useful when you wish to manipulate groups of files using mv, cp and del. be very careful when using del *!
In normal operation, most programs take input from the keyboard and display the results on the screen. These are known as standard input and standard output respectively. However, if a program produces a large amount of output, it might be desirable to catch this in a file instead. The shell provides this output redirection facility using the greater-than character >. We used the greater-than output redirection operator in tutorial 1 to provide a "quick and dirty" way of creating a file as follows:
$ cat > myFile some text
We can use redirection with many Unix commands. Try:
$ ls > out.file
$ more out.file
In the same way that you can redirect output you can also redirect input. Try the following sequence of commands.
$ echo 13 9 1997 > in.file
$ more in.file
$ cal < in.file
A similar idea to redirection is the Unix structure known as a pipe. This runs
two or more programs in such a way that the output from one is used as the
input to another. A pipe is represented by the vertical bar (or pipe) character |. Try:
$ ls | sort -r The shell keeps a record of recent commands given to it, and these can be
recalled and re-issued. This can save typing when the same or similar
commands are being used repeatedly. Try the following. Hold down the "ESC" (ESCape) key and press the "k" character
key a few times. The last few commands that you issued will appear. To step through the list in the opposite
direction press the "j" key (while still holding down the "ESC" key). By stopping at any of your past commands,
releasing the "ESC" key and pressing the command can be reissued. It is also possible to
edit commands recalled in this manner using an editing mode based on the standard
Unix editor vi.
Appendix C.4 in the Introductory Guide gives
details concerning the vi editor. To see your complete command history try the following: $ history Another way of saving on typing is to cut and paste. Find a command in
your command history which should still be visible in one of you windows, place the mouse cursor at the start of
the command (not the reference number), hold down the
left button of the mouse and drag over it to the right. The command will be highlighted. Now release the left
button, move the mouse cursor to another window and click the middle button. You have just cut some text
out of one window and pasted it into another. You can now execute the command if you wish. (You
can also "cut and paste" from and to the same window). In a similar manner you can cut text from
WWW pages.
An important means of communication, using computers, is electronic mail (or email). Email allows you to
communicate with anybody around the world who has a computer with appropriate software and
the required network connections. Many email software packages exist. We will be
using Elm. To invoke Elm type the command: $ elm You will see som text of the form: Followed by a list of email messages in your email directory (if any), followed by:
Your tutor will now demonstrate how to send and receive email.
Try sending a message to you tutor! For further information regarding email refer to the
Electronic Mail section in the Introductory
Guide. CS (Computer Science) News provides a mechanism whereby general announcements, and items
of relevance to individual year groups can be disseminated. A summary of these announcements is
displayed as part of the login process. Typically you will see something like: when you log in. To read the full text of these announcements, use the command csnews: $ csnews You will see some text of the following form: This lists the names of the announcement groups, together with a short
description of the type of announcement that will appear there. The number
of unread announcements in each group is given after the index number (e.g.
lucs.announce.software has 19 unread announcements in the above example). Your tutor will now give you a brief demonstration on how to read announcements in a particular group. Now try experimenting with some of the commands. For more detailed information regarding CSNEWS (and related
matters) refer to the announcements section in the
CS "Introductory Guide". Now exit from CSNEWS, make sure one your window's current directory is your 2CS21 directory
and "cut" the following
command out of this window and "paste" it into your "2CS21 window": $ cp ~frans/public_html/2CS21/week2/sum_and_prod.ada . (make sure you catch the dot at the end).
You have now copied the source code for the "sum and product" Ada program introduced during last
week's lectures into your 2CS21 directory. You can
view the source code using more. Now compile it using the ICC
command as follows: $ ICC sum_and_prod.ada Check your directory using lsf. A number of files and a directory have been created. One of the created
files is called simply sum_and_prod.
This is the load module or executable generated from the given source code. Now
execute the load module: $ sum_and_prod and respond to the prompt for input. Try inputting different integers. What happens if you enter a character
other than an integer? Make a copy of the sum_and_prod.ada file using the cp command. Now, using the ved text
editor, add two extra lines to the program so that it also produces the square of each of its inputs.
Recompile the source code and execute your revised version. Try introducing some other variations and/or
additions! At the end of the session logout in the same manner as you did at the end of the previous session. (Note
that we will not
be using the "myfiles" again so you can delete them if you like.) Created and maintained by
Frans Coenen.
Last updated 11 October 1999
4. COMMAND HISTORY
5. CUTTING AND PASTING
6. ELECTRONIC MAIL
Mailbox is '/usr/mail/frans' with 62 messages [ELM 2.4 PL24]
You can use any of the following commands by pressing the first character;
d)elete or u)ndelete mail, m)ail a message, r)eply or f)orward mail, q)uit
To read a message, press
6. CS NEWS
[lucs.announce]
117 Computing Service News access
118 pstud1 and pstud2 changes
119 Systems downtime
120 Acknowledgement of Regulations
121 Software Problems (particularly 'olvwm')
122 UNIX filestore doc
123 UNIX working space
124 Next CSCW North Meeting
125 Flooding in Chadwick Lab. D
126 Next CSCW North Meeting - Timetable
127 Mains Electricity Testing and Systems Downtime
u 1 12 lucs.announce
u 2 lucs.announce.year1
u 3 28 lucs.announce.year2
u 4 9 lucs.announce.year3
u 5 lucs.announce.mscs
u 6 19 lucs.announce.software
u 7 lucs.jobs.staff
u 8 lucs.jobs.student
8. COMPILING ADA SOURCE CODE
8.1 Editing the source code.
9. AT THE END OF THE SESSION