Quick Answer: How Do I Print an Array in Linux?
Contents

How do I print an entire array in Linux?

Bash Script

  1. #!/bin/bash.
  2. #Script to print all the elements of the array.
  3. #declaring the array.
  4. declare -a example_array=( “Welcome””To””Javatpoint” )
  5. #Printing all the elements.
  6. echo “${example_array[@]}”

How do you print an array element in Unix?

To refer to the value of an item in array, use braces “{}”. The braces are required to avoid issues with pathname expansion. To write all elements of the array use the symbol “@” or “*”.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest