INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

bash script store array1 contents into new array problem

bash script store array1 contents into new array problem

bash script store array1 contents into new array problem

(OP)
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

RE: bash script store array1 contents into new array problem

(OP)
btw, I have a type in the for loop. the i= should be i++
the problem still persists though ...

RE: bash script store array1 contents into new array problem


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

RE: bash script store array1 contents into new array problem

(OP)
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 ..?

RE: bash script store array1 contents into new array problem

Hi

There is a syntax error : you can not have spaces around the equal sign ( = ) :

CODE --> Bash

# wrong
List2[i-1] = ${List[i-1]}

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

Feherke.
feherke.ga

RE: bash script store array1 contents into new array problem


Ooops....noevil

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

RE: bash script store array1 contents into new array problem

(OP)
feherke,

thanks, I'll try that when I go back to the office. Thanks!

RE: bash script store array1 contents into new array problem

(OP)
Thanks feherke!! Works now

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close