Menu

(Solved) : Exercise Create Script Called Stringopssh Uses Various String Operators Stringopssh Script Q44109335 . . .

  • In this exercise, you will create a script calledstring_ops.sh that uses the various stringoperators
  • The string_ops.sh script will
  • Use one command line argument, which will be”Hello
  • Assign the value of the first argument to a local variablecalled STRING. HINT: Look at line 5 in the examplescreenshot for arguments.sh
  • Use four IF THEN statement to compare thevalue of local variable STRING
  • Determine which string operators to use to produce thefollowing output when run

WARNING: In the IF THEN statements, to avoidsyntax error messages, there must be a spacebefore and after each bracket and also betweeneach element within the brackets.

The first IF THEN statement has the form

if [ “$STRING”   operator “string”]

then

           echo “<message>”

fi

  • Decide which operator to use in the comparisonthat produces the first message. Look at the slide “StringOperators
  • Decide what the value of string should be
  • Decide what the message should be
  • The second IF THEN statement has the form

if [ “$STRING”   operator “string”]

then

           echo “<message>”

fi

  • Decide which operator to use in the comparisonthat produces the second message. Look at the slide “StringOperators
  • Decide what the value of string should be
  • Decide what the message should be
  • The third IF THEN statement has the form

If [   operator “$STRING” ]

then

           echo “<message>”

fi

  • Decide which operator to use that produces thethird message. Look at the slide “StringOperators
  • Decide what the message should be
  • The fourth IF THEN statement has the form

if [   operator “$2” ]

then

           echo “<message>”

fi

  • Decide which string operator to use thatproduces the fourth message. Look at the slide “StringOperators
  • Decide what the message should be

Expert Answer


Answer to In this exercise, you will create a script called string_ops.sh that uses the various string operators The string_ops.s…

OR