Declaring Array
array_name[index]=value
See Below Example.
Example
TUTORIAL[0]="shell scripting" TUTORIAL[1]="awk" TUTORIAL[2]="sed"
You Can access single Element of an Array by using following Command
${array_name[index]}
See Below Example.
#!/bin/sh TUTORIAL[0]="shell scripting" TUTORIAL[1]="awk" TUTORIAL[2]="sed" echo "First Tutorial: ${TUTORIAL[0]}" echo "Second Tutorial: ${TUTORIAL[1]}"
you can access all Elements of an Array by Using following Command.
${array_name[*]} ${array_name[@]}
See Below Example.
#!/bin/sh TUTORIAL[0]="shell scripting" TUTORIAL[1]="awk" TUTORIAL[2]="sed" echo "All Tutorial - Method 1: ${TUTORIAL[*]}" echo "All Tutorial - Method 1: ${TUTORIAL[@]}"
See You Soon....
0 comments:
Post a Comment
Ask anything about this Tutorial.