Make an array called array with three elements in it, a hashmap /dict / associative array called hash with three elements in it, and a string variable called str with at least 15 characters where one of those characters is duplicated twice (i.e., in the string at least 3 times). hint: declare -a array #creates an index array & declare -A hash #creates an associative array Use echo to print both your arrays (both ‘array’ and ‘hash’) as strings on a single line. (Use loops) Save just a portion of your indexed array to a new array variable. Write a loop to print out each item of the new array on a line by itself. Remove the last element from your indexed array. Remove the first element from your index array. Use echo to print out your indexed array on a single line. Use an if statement to do this: If your array contains 2, print “true” otherwise print “false” Create a read-only string variable and demonstrate that it cannot be changed. Echo a substring of str which does not contain the first or last characters of str. Echo the last bit of str that does not contain the thrice-repeated character from step 1. Echo every part of str after the first instance of the thrice-repeated character. Write an expression that echoes the value of an unset variable, but have the parameter expansion replace the unset variable’s value with any value you want and assign the variable to this value. Echo the now-set variable from 13.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

  1. Make an array called array with three elements in it, a hashmap /dict / associative array called hash with three elements in it, and a string variable called str with at least 15 characters where one of those characters is duplicated twice (i.e., in the string at least 3 times).

    hint: declare -a array #creates an index array & declare -A hash #creates an associative array

  2. Use echo to print both your arrays (both ‘array’ and ‘hash’) as strings on a single line. (Use loops)

  3. Save just a portion of your indexed array to a new array variable.

  4. Write a loop to print out each item of the new array on a line by itself.

  5. Remove the last element from your indexed array.

  6. Remove the first element from your index array.

  7. Use echo to print out your indexed array on a single line.

  8. Use an if statement to do this: If your array contains 2, print “true” otherwise print “false”

  9. Create a read-only string variable and demonstrate that it cannot be changed.

  10. Echo a substring of str which does not contain the first or last characters of str.

  11. Echo the last bit of str that does not contain the thrice-repeated character from step 1.

  12. Echo every part of str after the first instance of the thrice-repeated character.

  13. Write an expression that echoes the value of an unset variable, but have the parameter expansion replace the unset variable’s value with any value you want and assign the variable to this value.

  14. Echo the now-set variable from 13.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education