CSCI212 Assignment 3

This assignment requires to write a standalone Point of Sale (POS) program using the Bourne-again Shell (bash). The POS program is normally used at the checkout counter in a shop or restaurant to serve as an electronic cash register. It is a menu-based, allowed to use options: such as adding, removing, editing and reporting.

In this program, you are required to use the shell command such as echo, grep, awk, cut, piping, expr, read, sort, etc to store, locate, display, remove and sort the transactions.

It also involves the control structures, case structure, while and for-loop.

By combining the shell commands together, we could easily achieve some powerful assets.

This is a menu writing programming that we used to do it often. The only difference is the file structure. Firstly, this is how the program works.


The main program file is POS.sh, however, all other important functions are done only in POS_functions.sh.

During execution, especially for sorting by date and summary report, several documents are being created to store the values temporary.

Tips for bash programmer

  • To begin a bash program, it is important to insert #!/bin/bash in order to inform that we are using the bash shell.
  • For commenting, you can use the symbol # at the beginning of the line.
  • Function call can be done. To use arguments in the function, we can get them by $1, $2, etc.
  • Receiving input from keyboard can be done by using read command.
  • echo does the same function as print function, where echo, by default, point at next line, unless there is option -en is mentioned.
  • export is similar to global variable in other programming.
  • grep is a powerful and useful for graping the piece of information.
  • awk is another powerful tool for writing the program. The awk is in fact not well known and GNU version of awk, called gawk, sound unfamiliar. It can be used for text processing and report generation by using best part of languages like C, python and bash.
  • tr is used to translate characters into other characters or delete them.
  • As the name mentioned, cut command can pull data from given range and useful while working with string.
 

No comments:

Post a Comment