toxic_boi_8041
toxic_boi_8041

Reputation: 1492

Variable Assignment in Bash Script

I have seen one syntax in bash script for variable assignment. probably i am not getting what is use of it.

Syntax is :

VarName=()

Thanks.

Upvotes: 1

Views: 152

Answers (2)

paxdiablo
paxdiablo

Reputation: 882446

The bash shell has simple variables and one-dimensional array variables. That one is simply creating an empty array.

You can see the effect in the following transcript which creates arrays of varying sizes and shows you their size:

pax> x=(1 2 3 4 5) ; echo ${#x[@]}
5
pax> x=(1) ; echo ${#x[@]}
1
pax> x=() ; echo ${#x[@]}
0

Upvotes: 2

Jack Wasey
Jack Wasey

Reputation: 3440

Try reading the documentation. See https://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameters

VarName=1
VarName="two"

Upvotes: 0

Related Questions