The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-06-2008
balamv balamv is offline
Registered User
  
 

Join Date: May 2008
Posts: 24
Question How to assign a variable value to array?

The below script is not working. Could anyone help me on this?

#!/bin/bash
dirs="not_using_0"
for entry in *; do
[ -d "$entry" ] && dirs="$dirs $entry"
done
dirarray= ($dirs)


output is
---------

arrayshell.sh: syntax error at line 6: `dirarray=' unexpected

How to assign a varibale value in array

array= ($variable) ? is this correct?