Software 1, Spring 2004

0368215712
Lecture: Tuesday 10:00-13:00, Orebstein 5 (Dach)

Instructor: Dan Halperin
Office hours: Tuesday 15:00-16:00, Schreiber 219

Teaching Assistants: Greta Yorsh and Efi Fogel
All practice-related information can be found at the Practice website

Helpdesk:
Ori Shalev, [email protected], Tuesday, 17:00-19:00
Angela Enosh, [email protected], Wednesday, 19:00-21:00

The course will cover three topics:

  1. the C programming language,
  2. basic system software and the UNIX programming environment,
  3. a brief introduction to C++.

A short bibliography for the course.

The main textbook used in the course: A Book on C—3rd or 4th Edition, by Kelley and Pohl. The book is at its 4th edition, but for all the course’s purposes the 3rd edition is as good. One of the advantages of this book is that its example programs are available on-line: browse the examples or download the dos version.

The final grade will be determined by your assignments grade (25%) and the final exam (75%). To be eligible for a final grade students must submit ALL exercises. Note that the exercises do not necessarily have equal weight in the final assignment grade. The assignments distribution and submission will be coordinated by the TAs (METARGELIM).

During the course you will need an account on the school’s UNIX machines. Most of you probably have an account already. If not check with the help desk on the entrance floor to Schreiber.


Syllabus and Handouts

The chapters below refer to the chapters of “A Book on C”—3rd or 4th Edition. Note that this course outline is tentative. During the semester we also maintain a brief summary of the actual material taught in class.

course overview. requirements.
introduction to “C” (chapter 0)

example programs in C (chapter 1)

a brief history of the UNIX operating system
Beginner’s Unix commands

lexical elements (chapter 2)

writing a C program in UNIX

fundamental data types (chapter 3)

floating point standards and signed numbers; for more details see “Computer Arithmetic” by David Goldberg, Appendix A of “Computer Architecture, a Quantitative Approach” by Hennessy and Patterson, 2nd Edition, Morgan Kaufman.

flow of control (chapter 4)

random number functions from the book “Programming Abstractions in C” by E. Roberts, Addison Wesley,
and a small program that tests some random number functions and sample runs

functions (chapter 5)

runtime environment and the control stack; for more details see “Runtime Environments”-Chapter 7 of “Compilers, Principles, Techniques and Tools” by Aho, Sethi, and Ullman, Addison Wesley.

arrays, pointers, and strings (chapter 6)

structures (chapter 9)

dynamic matrix allocation (from chapter 12), matrix.tgz—the source code and makefile

preprocessor (chapter 8)

bitwise operators and enumeration types (chapter 7)

self-referential structures and linked lists, binary trees (chapter 10)

stacks (also from chapter 10)

introduction to the unix make untility (type “unix make untility” in google to find more on-line guides/manuals)

input/output, files (chapter 11)

for more information on UNIX I/O, see Advanced Programming in the UNIX Environment / W.R.Stevens, Addison-Wesley.

executing commands from within a C program

environment variables

lint, profiler

timing a C program, using pipes from within a C program

compilation options, making a library, timing C programs

For the class on 18/5/04 please download the following two handouts:
(1) More on make
(2) Introduction to PERL

process control in UNIX, pipes, signals (chapter 12)

about shell scripts and scripting languages

new: secure programming , guest talk by Yedidyah Bar-David on 8/6/04

UNIX utilities (those will be mainly studied in the TIRGUL): sort, find, tar, gzip, uuencode/decode, background, fg, jobs, soft links

a brief introduction to C++

Perl


Perl “hello” example

  • Simply say
    print \"Howdy, world!\n\";
    
  • To execute:
    "perl -e "print \"Howdy, world!\n\";""
    
  • Or, edit the file hello to contain the one-liner program above, and type:
    perl hello
    

Perl language

  • Designed to work smoothly in the same ways that natural language works
    smoothly
  • Easy things should be easy, and hard things should be possible
  • On the other hand, the camel has not evolved to smell good. Neither has
    Perl

Perl Poetry

  • A perl poem by christo, chris lacy-hulbert, October 12th 2003
    #!/usr/bin/perl
    
    untie $me; open $doors;
    for($ever){ join
    $me, 'and', $you;
    last or sleep and die;}
    
    map $our $future or kill my $hopes;
    my %hope = ('to','be','with','you');
    open $doors unless $I& break;
    $Read= each %hope and wait;
    
    times; shift and tell;
    warn my $friends; warn
    for($they_are_not_safe);
    $I& sort and study time;
    
    wait for($me);
    close $doors and sin
    bind (You_and, me);
    $please= wait and $see;
    
    if ($you){ chop( my $words);}
    my %hopes& break and die ;
    if($you){split 'from', $me;}
    $I= 'cry' and die 'inside';
    

Perl Variables

  • Scalar and others
    Variable Syntax
    Type Character Example Is a name for:
    Scalar $ $cents An individual value (number or string)
    Array @ @large A list of values, keyed by number
    Hash % %interest A group of values, keyed by string
    Subroutine & &how A callable chunk of Perl code
    Typeglob * *struck Everything named struck
  • Spring into existence with nothing in them when needed
    • No need to declare
    • Initialized with 0, null, “”, depending on the context

Singularities

  • Scalars are assigned a new value with the = operator
    $answer = 42;               # an integer
    $pi = 3.14159265;           # a "real" number
    $avocados = 6.02e23;        # scientific notation
    $pet = "Camel";             # string
    $sign = "I love my $pet";   # string with interpolation
    $cost = 'It costs $100';    # string without interpolation
    $thence = $whence;          # another variable
    $x = $moles * $avocados;    # an expression
    $cwd = `pwd`;               # string output from a command
    $exit = system("vi $x");    # numeric status of a command
    $fido = new Camel "Fido";   # an object
    

Pluralities

  • Array – look something by the number
  • Hash – look something by the name

Arrays

 

  • Ordered list
    @home = ("couch", "chair", "table", "stove");   # initialize
    ($potato, $lift, $tennis, $pipe) = @home;       # list
    ($alpha,$omega) = ($omega,$alpha);              # swap
    
  • 0 based
    $home[0] = "couch";
    $home[1] = "chair";
    $home[2] = "table";
    $home[3] = "stove";
    
  • Can push and pop to and from

Hashes

  • Each pair of items is interpreted as a key/value pair
  • Can be assigned from a list
    %longday = ("Sun", "Sunday", "Mon", "Monday", "Tue", "Tuesday",
                "Wed", "Wednesday", "Thu", "Thursday", "Fri",
                "Friday", "Sat", "Saturday");
    
  • Alternatively:
    %longday = (
        "Sun" => "Sunday",
        "Mon" => "Monday",
        "Tue" => "Tuesday",
        "Wed" => "Wednesday",
        "Thu" => "Thursday",
        "Fri" => "Friday",
        "Sat" => "Saturday",
    );
    
  • Its keys can be extracted from using the keys function
    • The keys can sorted using the sort function
  • Intuitive access:
    $wife{"Adam"} = "Eve";
    

Grade Example

  • A set of scores for each student:
    Noël 25
    Ben 76
    Clementine 49
    Norm 66
    Chris 92
    Doug 42
    Carol 25
    Ben 12
    Clementine 0
    Norm 66
    ...
  • Need to gather all their scores together, determine each student’s average,
    and print them all out in alphabetical order.

    #!/usr/bin/perl
    
    open(GRADES, "grades") or die "Can't open grades: $!\n";
    while ($line = <GRADES>) {
      ($student, $grade) = split(" ", $line);
      $grades{$student} .= $grade . " ";
    }
    
    foreach $student (sort keys %grades) {
      $scores = 0;
      $total = 0;    
      @grades = split(" ", $grades{$student});
      foreach $grade (@grades) {
        $total += $grade;
        $scores++;
      }
      $average = $total / $scores;
      print "$student: $grades{$student}\tAverage: $average\n";
    }
    

Filehandles

  • Filehandles are similar to streams
  • Use the open function to create a filehandle and attach it to a file
    open(SESAME, "filename");               # read from existing file
    open(SESAME, "<filename");              #   (same thing, explicitly)
    open(SESAME, ">filename");              # create file and write to it
    open(SESAME, ">>filename");             # append to existing file
    open(SESAME, "| output-pipe-command");  # set up an output filter
    open(SESAME, "input-pipe-command |");   # set up an input filter
    
  • The angle operator encloses the filehandle you want to read lines from
    print STDOUT "Enter a number: ";          # ask for a number
    $number = <STDIN>;                        # input the number
    print STDOUT "The number is $number\n";   # print the number
    
    • The empty angle operator, <>, reads lines from all the files
      specified on the command line, or STDIN, if none were
      specified
  • read does not automatically remove the newline from its input
    line

    chop($number = <STDIN>);    # input number and remove newline
    

Operators

  • Some binary operators
    Binary Arithmetic Operators
    Example Name Result
    $a + $b Addition Sum of $a and $b
    $a * $b Multiplication Product of $a and $b
    $a % $b Modulus Remainder of $a divided by $b
    $a ** $b Exponentiation $a to the power of $b
  • String operators
    $a = 123;
    $b = 456;
    $c = 3;
    print $a + $b;     # prints 579
    print $a . $b;     # prints 123456
    $b = 3;
    print $a * $c;     # prints 369
    print $a x $c;     # prints 123123123
    
  • Assignment Operators
  • Autoincrement and Autodecrement Operators
  • Logical Operators
  • Comparison Operators
  • File Test Operators
    Some File Test Operators
    Example Name Result
    -e $a Exists</td True if file named in $a exists
    -r $a Readable</td True if file named in $a is readable
    -w $a Writable</td True if file named in $a is writable
    -d $a Directory</td True if file named in $a is a directory
    -f $a File</td True if file named in $a is a regular file
    -T $a Text File</td True if file named in $a is a text file
  • Examples
    -e "/usr/bin/perl" or warn "Perl is improperly installed\n";
    -f "/vmunix" and print "Congrats, we seem to be running BSD Unix\n";
    

Control Structures

  • What Is Truth?
    • Any string is true except for “” and “0”
    • Any number is true except for 0
      • Any reference is true.
      • Any undefined value is false
    0          # would become the string "0", so false
    1          # would become the string "1", so true
    10 - 10    # 10-10 is 0, would convert to string "0", so false
    0.00       # becomes 0, would convert to string "0", so false
    "0"        # the string "0", so false
    ""         # a null string, so false
    "0.00"     # the string "0.00", neither empty nor exactly "0", so true
    "0.00" + 0 # the number 0 (coerced by the +), so false.
    \$a        # a reference to $a, so true, even if $a is false
    undef()    # a function returning the undefined value, so false
    

Control Structures

  • The if, else, elsif and unless statements
    unless ($destination eq $home) {
        print "I'm not going home.\n";
    }
    
    • There is no “elsunless” though
  • Iterative (Looping) Constructs
    • The while and until statements
    • The for statement
    • The foreach statement
    • Breaking out: next and last
      foreach $user (@users) {
          if ($user eq "root" or $user eq "lp") {
              next;
          }
          if ($user eq "special") {
              print "Found the special account.\n";
              # do some processing
              last;
          }
      }  
      

Regular Expressions

  • The simplest use of regular expressions is to match a literal expression
    while ($line = <FILE>) {
        if ($line =~ /http:/) {
            print $line;
        }
    }
    
  • The special variable $_
    while () {
        print if /http:/;
        print if /ftp:/;
        print if /mailto:/;
        # What next?
    }
    

Regular Expressions

  • Quantifiers – placed after the item being quantified
    • Match at least seven digits, but no more than eleven digits
      /\d{7,11}/
      
  • Minimal Matching – use of a question mark after any quantifier
    • Stops at the first colon rather than the last
      /.*?:/
      
  • Nailing Things Down – matching a special kind of “nothing” that depends on
    its surroundings

    • \b matches at a word boundary
    • Matches “Fred the Great” but not “Frederick the Great”:
      /\bFred\b/
      
    • Go to the next iteration of LINE loop if this line begins with #
      next LINE if $line =~ /^#/;
      
  • Backreferences – use parentheses to remember bits and pieces of what you
    matched

    • Swap the first two words of a string
      s/(\S+)\s+(\S+)/$2 $1/    
      

Regular Expressions Examples

  • Examples:
    s/^([^ ]+) +([^ ]+)/$2 $1/;   # swap first two words
    /(\w+)\s*=\s*\1/;             # match "foo = foo"
    /.{80,}/;                     # match line of at least 80 chars
    /^(\d+\.?\d*|\.\d+)$/;        # match valid number
    
  • Pull fields out of a line
    if (/Time: (..):(..):(..)/) {
        $hours   = $1;
        $minutes = $2;
        $seconds = $3;
    }
    
  • Pull a substring out of a line
    if (/Version: *([0-9.]+)/) { $version = $1; }
    

List Processing

  • The list on the right side contains exactly four values:
    @array = (1 + 2, 3 - 4, 5 * 6, 7 / 8);
    
  • Some operators can produce either a scalar or a list value, depending on
    their context

    sort @guys, @gals, other();
    
    • Each of the LIST elements produces its list in turn, then
    • all the separate lists are joined together, end to end, into a single
      list.
    • The one-dimensional list is handed off to the function that wanted a
      LIST in the first place – sort
  • Filters and such
    print reverse sort map {lc} keys %hash;
    
    • Takes the keys of %hash and returns them to the map function, which
    • lowercases all the keys by applying the lc operator to each of
      them, and passes them to the sort function, which
    • sorts them, and passes them to the reverse function, which
    • reverses the order of the list elements, and passes them to the
      print function, which prints them.

prev
top


Make


Interpreters

  • Interpreter – a program that executes other programs.
  • perl – a stable, cross platform programming language, and the name of the interpreter
  • make – a program for directing recompilation (and other rerun of processes).
  • Compiler vs. Interpreter modelscompilerinterpreter

A program for directing recompilation

  • GNU make
  • Automatically determines which pieces of a large program need to be
    recompiled, and issues commands to recompile them
  • Not limited to C programs

Motivation

  • Complex projects
    • Many lines of code
    • Multiple components
    • More than one programmer
  • Division to components is desired
    • Long files are harder to manage (humans and machines)
    • Every change requires long compilation
    • Many programmers can not modify the same file simultaneously

The makefile structure

  • target … : prerequisitescommand
  • simple example
    prog: prog.o
    	gcc prog.o -o prog
    prog.o: prog.c
    	gcc -Wall -c prog.c
    
  • The goals are the targets that make should strive ultimately to update
  • Other targets are updated as well if they appear as prerequisites of
    goals, or prerequisites of prerequisites of goals, etc.

The make process

  • Each changed C source file is recompiled
  • Each C source file that includes a changed header file is recompiled (to
    be safe)
  • Each compilation produces an object file corresponding to the source file
  • If any source file has been recompiled, all the object files (newly made
    made or saved from previous compilations), are linked together to produce
    the new executable

Running make

  • Edit a file called the makefile that describes the relationships
    among files in your program and provides commands for updating each file in
    make format
  • Type:
    make
    
  • By default make tries the following in order:
    • GNUmakefile
    • makefile – best choice, if source-file names start with upper case
    • Makefile – best choice, if source-file names start with lower case
  • To tell make to read the file name as the
    makefile, type:

    make -f name
  • By default, the goal is the first target in the makefile
  • Specify a different goal or goals with arguments to make
    • Several goals are made in the order specified
    make target1 target2 target3
    

Another example

  • btree example – source files: prog.c btree.c btree.h
  • Project structure and dependencies can be represented as a DAG
    prog: prog.o btree.o
    	gcc prog.o btree.o -o prog
    
    btree.o: btree.c btree.h
            gcc -c btree.c -o btree.o
            
    prog.o: prog.c prog.h
            gcc -c prog.c -o prog.o
           
    clean:
    	rm -rf btree.o prog.o prog
    
    compiler

Variables make makefiles simpler

  • btree example
    CSOURCES = prog.c btree.c
    OBJECTS = $(CSOURCES:.c=.o)
    
    prog: $(OBJECTS)
    	gcc $? -o $@
    
    btree.o: btree.c btree.h
            gcc -c $< -o $@
            
    prog.o: prog.c prog.h
            gcc -c $< -o $@
           
    clean:
    	rm -rf btree.o prog.o prog
    

Pattern Rules

  • Instructs make that the command `bison -d x.y‘ will make both x.tab.c and x.tab.h
    %.tab.c %.tab.h: %.y
    	bison -d $<
    

Implicit Rules

  • Predefined rules always available
  • Compiling C sourse
    %.o : %.c
    	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    
  • Linking objects
      x: y.o z.o
    
    • when `x.c’, `y.c’ and `z.c’ all exist

Adding dependencies

  • btree: prog.o btree.o
    btree.o: btree.h
    prog.o: btree.h
           
    clean:
    	rm -rf btree.o prog.o prog
    

Shorter makefile (more generic)

  • Using variables, implicit rules and pattern rules
    CSOURCES = btree.c main.c
    OBJECTS = $(CSOURCES:.c=.o)
    TARGET = btree
    CPPFLAGS =
    CFLAGS = -Wall -pedantic
    
    $(TARGET): $(OBJECTS)
            btree.o: btree.h
    prog.o: btree.h
    clean:
            rm -rf $(OBJECTS) $(TARGET)
    
  • The output
    gcc -Wall -pedantic   -c -o btree.o btree.c
    gcc -Wall -pedantic   -c -o main.o main.c
    gcc -g  btree.o main.o   -o btree
    

Example: photo

  • linux gcc (gnu) makefile
    CSOURCES = photo.c
    OBJECTS = $(CSOURCES:.c=.o)
    TARGET = $(CSOURCES:.c=)
    CPPFLAGS =
    CFLAGS = -Wall -pedantic
    LDFLAGS = -lglut
    
    $(TARGET): $(OBJECTS)
    clean:
            rm -rf $(OBJECTS) $(TARGET)
    

Example: photo

  • Windows gcc (gnu cygwin) makefile
    CSOURCES = photo.c
    OBJECTS = $(CSOURCES:.c=.o)
    TARGET = $(CSOURCES:.c=)
    CPPFLAGS =
    CFLAGS = -Wall -pedantic
    LDFLAGS = -lglut32 -lopengl32
    
    $(TARGET): $(OBJECTS)
            gcc $(OBJECTS) $(LDFLAGS) -o $@
    clean:
            rm -rf $(OBJECTS) $(TARGET)
    

Example: photo

  • Windows cl (MSVC) makefile
    CSOURCES = cp_photo.c
    OBJECTS = $(CSOURCES:.c=.obj)
    TARGET = $(CSOURCES:.c=.exe)
    CPPFLAGS =
    CFLAGS = -nologo -I.
    CPPFLAGS =
    LDFLAGS = -nologo -subsystem:console glut32.lib opengl32.lib
    
    $(TARGET): $(OBJECTS)
            link $(OBJECTS) $(LDFLAGS) -Out:$@
    %.obj : %.c
            cl $(CFLAGS) -c $<
    clean:
            rm -rf $(OBJECTS) $(TARGET)
    

Example: photo

  • Combined makefile
    ifeq ($(OS), Windows)
    CSOURCES = cp_photo.c
    OBJECTS = $(CSOURCES:.c=.obj)
    TARGET = $(CSOURCES:.c=.exe)
    CFLAGS = -nologo -I.
    LDFLAGS = -nologo -subsystem:console glut32.lib opengl32.lib
    else
    CSOURCES = photo.c
    OBJECTS = $(CSOURCES:.c=.o)
    TARGET = $(CSOURCES:.c=)
    CFLAGS = -Wall -pedantic
    ifeq ($(OSTYPE), linux)
    LDFLAGS = -lglut
    else
    LDFLAGS = -lglut32 -lopengl32
    endif
    endif
    CPPFLAGS =
    
    $(TARGET): $(OBJECTS)
    ifeq ($(OS), Windows)
            link $(OBJECTS) $(LDFLAGS) -Out:$@
    else
            gcc $(OBJECTS) $(LDFLAGS) -o $@
    endif
    
    %.obj : %.c
            cl $(CFLAGS) -c $<
    clean:
            rm -rf $(OBJECTS) $(TARGET)
    

top
next


Beginner’s Unix Commands


Search google with “Beginner’s Unix Commands”.

There are many Unix commands that you might find
useful, and there are many opinions about what commands you should
make an effort to learn when you start.
This page offers some suggestions for getting started with Unix.

Preliminaries

To begin with, you need to have some notions about the files, directories,
and the Unix file system.
You should know what your home directory is.

You need to know some things about passwords, about connecting to the system,
about logging in and logging out.

Sources of Information

Most Unix systems have documentation on-line. You should note these items:

man word
If the on-line manual contains a “page” about word, this
command will display it on your screen.
For example, man man displays information about the
man command.
apropos keyword
The apropos command locates commands by keyword lookup.
When you type the command apropos word you will see a list of one-line
descriptions of entries in the manual that contain word (in their
one-line description).
Follow up by using the man command to display one of the manual pages.If you have lots of time and energy on your hands, you may want to
learn more about Unix on your own.
There are lots of books about using Unix;
you might want to get one and study it.
Books about Unix vary widely
in quality.
Before you buy a book about Unix, you might want to ask your instructor
for recommendations.

 

Some commands to learn about

If you think you need more information, use the man command
(see above), or talk to your instructor.

cd
The command

        cd directory_name 

changes your current (working) directory to the named directory.
The command

        cd

(i.e., with no arguments) changes
your current directory to be your home directory.

logout
Logs you out of the system.
ls
The command

        ls

(with no arguments) lists the
names of files in your current directory.

Adding the options -CF, i.e., typing the command

        ls -CF

lists the names of the files in your current directory,
listing them in multiple columns and appending a ‘*’ to executable files and ‘/’
to directories.

The command

        ls -l

shows a long-form listing
which includes a character indicating whether the file is a directory (‘d’)
or an ordinary file (‘-‘), 9 characters describing the file permissions,
the name of the file’s owner, the file’s size in bytes, when the file
was last modified, and the file’s name.

Any of these forms can have wildcarded file names appended to them;
that is, you can type things like:

        ls -l  file_name
        ls -l  wildcarded_file_name
        ls -CF file_name
        ls -CF wildcarded_file_name

These forms restrict the listing to files whose names match the wildcarding.

There are lots of other things ls can do; consult the manual page
(type the command man ls) for details.

mkdir
The command

        mkdir directory_name

creates a directory with the given name.

passwd
The command passwd (with no arguments) can be used to
change your password.
You will be prompted to enter your old password and to enter a new one twice.
Nothing will be echoed.
If the command doesn’t generate error messages, your password has been changed
to the new one.
pwd
The command pwd (with no arguments) displays the name
of your current directory on the screen. If what you see appears to be an
error message, consult your instructor.
rm
The command

        rm file_name

removes (deletes, erases) the named file.
The argument file_name can be replaced with a wildcarded
file name description; the command will remove all files that match
the wildcarded name.
Use wildcards here with great caution; there is typically
no way to recover a file that you have removed.

A variation on this command is the command

        rm -i file_name

The difference between this form and the first is that when the -i
is there, the rm command will ask you whether to remove a file
before it actually removes it. You can say no (‘n’).

Here are some other commands that you might find useful.
They’re here in alphabetical order.
If you think you need more information, use the man command
(see above), or talk to your instructor.

cat file_name
This command displays the named file on the screen.
Actually that is a special case of what the cat command does.
The command line:

        cat file_1 file_2 ... file_n

Reads the named files (file_1, file_2, …) and combines them into
a single file (concatenates them) which it sends to
“standard output” — the screen.
The command line:

        cat file_1 file_2 ... file_n > destination_file

concatenates the named files and puts the result in the file named
destination_file.

cp
The command

          cp file_1 file_2

copies the content of file_1 to a file named file_2.
After the operation you have two independent copies of the same information.

The command

          cp file_1 file_2 ... directory_name

puts copies of
the files, file_1, file_2, …, in the directory directory_name.
After the copy file_1 and directory_name/file_1
are independent copies of the same information.
Likewise with file_2 and directory_name/file_2, and so on.

date
The date command (with no arguments) prints the current
date and time. The output includes the day of the week too.
For example, if I now type the command, I’ll see this on my screen:

% date
Wed Sep 11 14:50:39 EDT 1996
% 
finger
The command

        finger

(with no arguments) displays some information
about people who are currently logged on.

The command

        finger user_name

displays some information
about the named user.
The command

        finger real_name

where real_name
is part of some user’s real name, should show some information
about that user.

The command

        finger user@internet_address

asks the system
at internet_address for finger information on user.
What happens depends on the system at internet_address;
that system might send the information, might send some other message
(perhaps a refusal), might “refuse the connection”, or just might
not respond (generating a long delay followed by a “connection
timed out” message.

lpr printer file_name
Sends the file to the specified printer.
more file_name
less file_name
These two commands are “pagers”. A “pager” is a program
that displays a file on your screen a screen-full at a time.
More is the older program, and there are many versions
of it. Currrent versions are usually capable of scrolling both forward and backward
in the file and of doing searches.
Less is more only more-so ;-).
There are lots of versions of less around.
Typically, less has more features than more.If you type a lower case ‘h’ to either of these programs, you should
see a “help screen”.
mv
The command

        mv file_1 file_2

moves file_1 to a file named file_2.
After the operation file_1 is gone and file_2
contains the information.
The effect is that file_1 is renamed as file_2.

The command

        mv file_1 file_2 ... directory_name

moves the files, file_1, file_2, …, to the directory directory_name.
After the move, files file_1, file_2, … appear in the named
directory rather than where they were.

rmdir
The command line

        rmdir directory_name

will remove the named directory if the directory is empty.
If there are files in the named directory, the command will tell you that
the directory isn’t empty and will not remove the directory.

who
The who command, without an argument, lists the login name, terminal
name, and login time for each current UNIX user.With two arguments, as in who am I who tells
who you are logged in as.

Software 1, Class Summary
Below you’ll find a brief description of what was taught in class.
“ABC” stands for the main textbook of the course:
“A Book on C”—3rd or 4th Edition, by Kelley and Pohl.
This page is meant to help people who missed class to get an idea of
the topics taught. It should not however be taken as a complete
description of the course material.

<! There’s also a page of >
<! a HREF=”http://www.math.tau.ac.il/~sariel/TA/99a/soft99a/tirgul.html”>
<! TIRGUL summary>
<! /a>
<! P>

 2.3.2004
course overview; requirements
introduction to “C”
example programs in C (chapter 1, up to getchar)

 9.3.2004
example programs in C (chapter 1, cont’d)
basic commands in UNIX
lexical elements (chapter 2)
fundamental number types (chapter 3)

 16.3.2004
fundamental number types (chapter 3, cont’d)
a little about computer arithmetic: representing signed integers,
floating point numbers; for more details see “Computer Arithmetic” by David
Goldberg, Appendix A of “Computer Architecture, a Quantitative
Approach” by Hennessy and Patterson, 2nd Edition, Morgan Kaufman.
flow of control (chapter 4)

 23.3.2004
functions, (chapter 5)
partial compilation (cc -o)
runtime environment and the control stack; for more details see
“Runtime Environments”-Chapter 7 of “Compilers, Principles,
Techniques and Tools” by Aho, Sethi, and Ullman, Addison Wesley.

 30.3.2004
arrays, pointers and strings (chapter 6, up till multi-dimensional arrays)

Software 1, Short Bibliography
C:

The main textbook used in the course:

 A Book on C —3rd or 4th Edition / Kelley and Pohl
Addison-Wesley
 Excellent, terse, by the C language designers:
The C Programming Language / Kerninghan and Ritchie
2nd Edition, Prentic Hall

UNIX:

 For UNIX programming (I/O, processes, pipes, etc):
<! old address before the author died:>
<! HREF=”http://www.kohala.com/~rstevens/apue.html”>

Advanced Programming in the UNIX Environment

W.R.Stevens.Addison-Wesley.

You can download the example programs in this book from the book’s website
 For UNIX utilities, Shells:
UNIX for Programmers and Users, A Complete Guide / Glass and Ables.
Prentice Hall, 2nd edition, 1999.
 More recent
UNIX: The Textbook / Sarwar-Koretsky-Sarwar
Addison-Wesley, 2001.

C++:

 The C++ Programming Language , 3rd Edition / Stroustrup
Addison-Wesley

Yair Oz - Webcreator

Contact