Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bash script store array1 contents into new array problem 1

Status
Not open for further replies.

rigstars2

Instructor
Dec 18, 2011
64
US
for ((i = 1; i <= 9; i=)); do
VAR=`sudo launchctl list | grep ${List[i-1]}` >/dev/null 2>&1
if [ "$VAR = "" ]; then
${List2[i-1]} = List[i-1] <---- the error says =: command not found ..what is wrong with my syntax
echo "${List2[i-1]}"
fi
done
 
btw, I have a type in the for loop. the i= should be i++
the problem still persists though ...
 

Try this:
Code:
. . .
  List2[i-1] = ${List[i-1]}
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
nice try LKBrwnDBA but still says command not found ..I've been searching google ..maybe you can't assign contents of array
to another array ..?
 
Hi

There is a syntax error : you can not have spaces around the equal sign ( = ) :
Bash:
[gray]# wrong[/gray]
List2[i-1][highlight #f66] [/highlight]=[highlight #f66] [/highlight]${List[i-1]}

[gray]# correct[/gray]
List2[i-1]=${List[i-1]}


Feherke.
feherke.ga
 

Ooops....[noevil]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
feherke,

thanks, I'll try that when I go back to the office. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top