Fill This Form To Receive Instant Help
Homework answers / question archive / Overview In this assignment you will write a single shell script to implement a tool to lookup, insert, and remove records in a table
In this assignment you will write a single shell script to implement a tool to lookup, insert, and remove records in a table.
The database table will be stored as one record per line in a file. Multiple tables are supported, one table per file. See the small for the required format. It is a TSV file.
While this task can be implemented more easily with multiple files, the point of this assignment is to understand how to use the shell to effectively manipulate a single file. So your database must use a single file to store the data. Secondary/temporary files can and should be used as needed.
Write a single POSIX compliant shell script that satisfies the following requirements:
dbfile create [table] [field1,field2,...]
create a new database table. If the table already exists then issue an error and do not create a new table.dbfile add [table] [value1,value2,...]
will add a single record to the table.dbfile list
must list the names of all the tables in the database.dbfile lookup [table] [query]
will show records that match the query. We want a somewhat performant database so this must only read the entire contents of the file/table once and only store one line/record at a time in memory.dbfile delete [table] [query]
must remove all records that match the querydbfile update [table] [query] [value1,value2,...]
must replace the record that matches the query with the new record.DBFILE_DATABASE
if provided, otherwise it is stored in the db
directory in the current working directory.src/dbfile
.For this assignment we will use the ShellCheck tool for linting. It can be installed by following these instructions.
For this assignment we will be using Bats for testing. It can be installed by following these instructions.
Before you start the assignment please consider reading the manual pages for the following commands:
grep
cut
sed
Since the tables are stored as CSV files the VS Code extension Rainbow CSV might be useful.
Please clone this repo with git clone
and then in the git repo run the following command to pull the GIT submodules.
git submodule update --init --recursive
Then create the file src/dbfile
, commit, ensure make test -B
passes and then push your code to GitHub. Make sure your GitHub action passes as expected. Please do not modify any files in this project other than file in src
.
Already member? Sign In