Question
This script will check the length of an argument string. Name this script strlench.sh. #!/bin/sh # some comment slen=expr $1 : '.*' echo $1 $slen
This script will check the length of an argument string. Name this script strlench.sh.
#!/bin/sh # some comment slen=expr "$1" : '.*' echo $1 $slen if [ $slen -lt 4 ] ; then echo String too short elif [ $slen -gt 10 ] ; then echo String too long else echo Goldilocks fi
LR(10/18): (2 pts.) Read the man page for expr and figure out why the first line of the file computes the length of the commandl line argument, $1. Document this in your lab report.
LR(11/18): (2 pts.) Test the script, then modify it to test 2 command line arguments, the first argument ($1) should be 2 to 8 chars long, the second command line argument ($2) should be 5 to 8 chars long. Document and show the modified script running.
LR(12/18): (2 pts.) Create another error by removing the backticks from the expr and see what error you get. Document your results.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started