ECE 8473 - Assignment #2 - Due: 29 Sept 2022


Upload source files - individual files or archive (e.g. zip, tar) - to your osp/a2 upload area.

Shell scripts should run correctly using dash.

Each script must start with a comment containing your name and a description.

References: susv4 sh, dash, head, tail, seq, test, test1, test2, test3


  1. [20] a2/p1.sh - join

    Write a shell script which joins successive pairs of lines from standard input and writes them to standard output.

    Use a loop to read lines from input. Do not use any temporary files or any external programs or utilities.

    Examples


  2. [30] a2/p2.sh - rotate

    Write a shell script to rotate lines from a text file and display the result to standard output:

      rotate N FILE
    
    Circular rotate N lines from FILE. The first N lines are skipped from the beginning and appended to the end of output.

    The script must print an error message and exit if there are too few or too many arguments.

    Use head and tail. Do not use any temporary files.

    Examples


  3. [50] a2/p3.sh - seq

    Write a shell script to implement the following version of the seq command:

      seq first last
      seq first increment last
    
    Print integer numbers from first to last in steps of increment.

    If increment is not specified, it defaults to 1 if first < last, or -1 if last < first.

    The script must print an error message and exit if there are too few or too many arguments, or if the specified arguments would produce no output or cause an infinite loop.

    Use only built-in shell commands and arithmetic, do not use any external programs or utilities.

    Examples