Very new to ubuntu here, and I have been assigned to create the prarg bash shell script below. Please bear with me I am trying to be very clear by providing all relevant examples.
ASSIGNMENT:
1. Modify the prargs program to precede each argument by its number. Thus, typing prargs a 'b c' d
should give the following output:
1: a
2: b c
3: d
The issue I'm having is the book example runs the following script by typing in "prargs a b c". When I type this I get the error: prargs:command not found
. How do I get the script to run this way? The only way I can run the script is with ./prargs.sh
or bash prargs.sh
.
Script contents:
while [ "$#" -ne 0 ]
do
echo "$1"
shift
done
Because I can't run it as directed, I am stuck. The directions and the book were very unclear, I can find snippets online but the main issue here is syntax for the entire code and I can't find that.
Help? and Thank you!
bash prargs.sh a b c
in the same directory as the file. Note that you wrotepargs
, which i assume was a typo. Once I set it to executable,./prargs.sh a b c
also worked. – Doug Smythies Nov 30 '19 at 17:25a 'b c' d
nota b c
. – WinEunuuchs2Unix Nov 30 '19 at 18:22