A bash program

Write a bash program

Comments start with an unquoted # which begins a word and end with a newline.
handling quotes is optional and complex – do this last for extra credit
lines without comments should not be changed
lines which begin with # should not be changed
other lines containing comments should have the comments moved
all comments should begin in the same column
2 columns after the end of the longest code (before comments)
example input

begins with

begins with space

A=(foo bar)
B=(bax qux) # comment
C=(aaa bbb) # don’t change indentation
echo ${#A[@]} # first # doesn’t begin a word
echo ” # not a comment”
echo \” # comment\”
echo \” # not a comment\”
example output

begins with

begins with space

A=(foo bar)
B=(bax qux) # comment
C=(aaa bbb) # don’t change indentation
echo ${#A[@]} # first # doesn’t begin a word
echo ” # not a comment”
echo \” # comment\”
echo \” # not a comment\”
Requirements
Use only bash and standard UNIX utilities:
do not use awk or other UNIX programming languages
Read from standard input, write to standard output:
do not use disk files for input or output
do not use command line parameters
output only processed input lines – no prompts, instructions, etc.
Documentation
Comments
include name, date, assignment
include brief instructions for using the program
include brief explanations of algorithms
include brief explanations of data structures
Use descriptive names for variables and functions.
Use a consistent style to indent code blocks.
Hints
start early, this may take longer than you expect
think about the structure of your data and logic before you write any code
with each revision add the smallest possible amount of code
test code with a variety of inputs
add comments as necessary
save your code under another name
Due Date
This assignment is due May 21 at 11:59 PM.
Email your program (where script.bash is the name of your file) with:
mail -s ‘assignment 3’ stuart < script.bash

find the cost of your paper

This question has been answered.

Get Answer