All pastes #779042 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-18 03:45 UTC
rendered paste body
 1) time date and location (whereami)
      Write a simple script that reports the time, date and the current working directory.

 2) Template
      Write a script that reads from input and substitutes the character sequence ## for
      the value of a parameter given to the script. Try to otherwise preserve the layout,
      especially line breaks.

 3) Indent
      Write a script to indent the input on its way to the output.

 4) Unindent
      Write a script to unindent the input on its way to the output.

 5) Generate a sequence of numbers

      Write a script to generate sequences of numbers. These can be
          a) simple for like loop, giving the start and end numbers and the step.
          b) A complex sequence like the Fibonacci sequence
             0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,
          c) A sequence where each is a multiple of the last, for example paper sizes
             (http://en.wikipedia.org/wiki/Paper_size)

 6) A script to maintain a simple diary of events such as a timetable
      A simple file can store events for a timetable
            day time duration             what
            monday         9       2      En008 study skills
            friday         12      2      cm545 operating systems
      two script can be written, one to add and delete entries, the other to display the

                                                                      
      timetable in a more readable form, either as a list (with nice indents) simple, or as a
      grid more complex.
 7) A simple address book program. Add, remove and display addresses.
      A simple file can hold an address book. A program script(s) can add, delete and
      search for entries.
            
 8) A simple shell
      Shells can be intimidating to the new user. Write a simple shell with a simplified set
      of commands. Each command can be a function call, and meaningful names can be
      tested for in a switchyard.

 9) Count words and lines in the input
      Read from standard input (or a file) and count the number of words and lines in the
      input. A word can be defined as a sequence of non space characters.
10) display information about a file, it's date, if it exists.

      For a given filename (or each file in a list) apply the following tests and print out the
      appropriate messages
          a) does it exist?
          b) is it writable?
          c) is it a file or directory?
          d) what is the file date?
          e) what is its size?

11) a wrapper for file operations, provides a menu and confirmation.
      New users can often inadvertently do things wrong, such as delete files, and forget
      commands. Write a script that takes a filename and provides a menu of actions that
      can be performed on the file. Apply the users choice and where appropriate ask for
      confirmation before doing anything drastic, like deleting the file.

12) Display a “message of the day”
      System managers often need to provide a message of the day with important
      information about the system. Write a script “motd” to display such a message.
      The message should be in a text file (to allow a manager to easily edit it),in a known
      location.

13) display the first n lines of the input.
      Write a script to display only the first n lines of its input. The number of lines
      should be given as a parameter to the script and the file read from standard input.

14) Generate a times table
      Write a script that given a number as a parameter writes out the times table for
      that number.
                                                                  CM0545 Operating Systems
15) generate a list of pixels
    Given the width and height of an image (as parameters) print out a list of the pixels
    coordinates.
    (0,0) (0,1) (0,2) ... etc .. (h,w)
16) very simple spell checker.
    Write a simple spell checker. Given a word list (in a known file) read from input and
    check to see if each word is in the word list. If a word cannot be found print it as
    output.
    For the ambitious. Prefix the word printed with the line number in the input where
    it was found.

17) Simple Make
    Given a list of files to create (each name ends in a .o) check to see if a
    corresponding source file exists (ending in .c). If it does, compile the file to
    generate the target (.o) file.
    For the purposes of this exercise you can just simply copy the source (.c) to the
    target (.o) rather than using a compiler.
    Extension: extend the exercise to use both .c and .s files. Files ending in .c are
    compiled (copied) into a .o file. Files ending in .s are assembled (copied) into a .o
    file.
18) Maintain a dictionary.
    Write a script to maintain a simple dictionary. Allow words to be added to the
    dictionary, ensuring that it is kept in the right order.
    For the ambitious include a definition of the word and write a script to look up the
    word and print its definition.

19) Backup management
    Within a set of files only some need to be backed up. Keep a list of files to be
    backed up in a text file. For a given directory find the filed to be backed up and
    copy them into a known backup directory (for example the cd-writer).

20) Version control
    Often it is useful to keep versions of a document to keep track of changes and
    archive older copies.
    A file needs to be checked into the version archive. A simple scheme is to add a
    version suffix number to the filename.
          memo.txt becomes memo.txt;1 memo.txt;2 memo.txt;3 etc
    Write two scripts (or one with a menu or parameter) that checks a file into the
    directory and automatically adds the next number in the sequence as a suffix. To
    check a version out of the archive, find the file with the requested version number
    and copy it out, removing the suffix. You may wish to ask before overwriting the
    existing file if it exists.