Skip to content
  • About
  • CoursesExpand
    • Problem Solving using C Language
    • Mastering Database Management
    • Linux System Administration
    • Linux and Shell Programming
  • Publications
  • Professional Certificates
  • BooksExpand
    • Books Authored
  • Patents
Download CV

Unix Arrays

Array Declarations

ARRAYNAME[INDEXNR]=value

or

ARRAYNAME=(value1 value2 …. valueN)

or

ARRAYNAME=([1]=10 [2]=20 [3]=30)

Defining Array Values

a[0]=1
a[2]=90
a[3]=100
a[4]=85
a[5]=65

To Print Single Element

echo ${arr[0]}
echo ${arr} – Prints first Element

To Print Array Value in Shell Script

#! /bin/bash

# To declare static Array
arr=(nishant vaibhav rishabh abhishek puneet)

# To print all elements of array
echo ${arr[@]}
echo ${arr[*]}
echo ${arr[@]:0}
echo ${arr[*]:0}

Scripts

Nishant Munjal

Coding Humanity’s Future </>

Facebook Twitter Linkedin YouTube Github Email

Tools

  • SIP Calculator
  • Write with AI
  • SamplePHP
  • Image Converter

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2025 - All Rights Reserved

  • About
  • Courses
    • Problem Solving using C Language
    • Mastering Database Management
    • Linux System Administration
    • Linux and Shell Programming
  • Publications
  • Professional Certificates
  • Books
    • Books Authored
  • Patents
Download CV
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok