ECE 8473 - Assignment #8 - Due: 1 December 2022


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

Shell scripts should run correctly using dash.

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


a8/p1.sh - hex words

Create a shell script which searches for words consisting only of the alphabetic hexadecimal characters [a-fA-F] and characters [oOlLsS] (letters O, L, S), and displays those words in lowercase, together with hexified versions: [oO] is replaced by 0 (number 0), [lL] is replaced by 1 (number 1), and [sS] is replaced by 5 (number 5). Assume that each line of input contains a single word.

Usage:

    dash hex.sh [-#] [file...]
The optional -# argument specifies a minimum acceptable word length, e.g. using -4 would cause it to only display hex words containing 4 or more characters. One or more input file names may optionally be specified on the command line. If no input file names are specified, the script will read from standard input.

Test using the provided words.txt file. which is available here and also in the VECR a8/ directory.

The script must use only standard Unix utility commands, such as cat, expr, grep, paste, sed, tr, etc. Do not use awk or perl and do not invoke the C compiler.

Sample Runs

$ wc -l words.txt
6256 words.txt
$ dash p1.sh words.txt | wc -l
3273
$ dash p1.sh -10 words.txt | wc -l
25
$ dash p1.sh -10 words.txt words.txt | wc -l
50
$ cat words.txt | dash p1.sh -4 | wc -l
2353
$ dash p1.sh -10 words.txt | tail -n 5
looseleafs 1005e1eaf5
obsolesced 0b501e5ced
saddleleaf 5add1e1eaf
saddleless 5add1e1e55
scaffolded 5caff01ded
$ dash p1.sh -11 words.txt
basellaceae ba5e11aceae
salsolaceae 5a1501aceae
coldblooded c01db100ded
$ dash p1.sh words.txt | grep 'food'
food f00d
foodless f00d1e55
foods f00d5
seafood 5eaf00d
seafoods 5eaf00d5
$