Skip to content
  • About
  • Courses
  • Publications
  • Professional Certificates
  • Books
  • Patents
  • ToolsExpand
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
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
  • EMI Calculator
  • Creative QR Code Generator Tool
  • Write with AI
  • Image Converter
  • SamplePHP

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2025 - All Rights Reserved

  • About
  • Courses
  • Publications
  • Professional Certificates
  • Books
  • Patents
  • Tools
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
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.