Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7837471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:39:08+00:00 2026-06-02T14:39:08+00:00

I am having problem when trying to assign a value to a variable in

  • 0

I am having problem when trying to assign a value to a variable in a loop. It will be like using variable inside a variable. So I created an array to add the values still something is not right.

Please take a look at the following KornShell (ksh) script and let me know where did I mess up

#!/usr/bin/ksh
set -A array $1 $2 $3
set -A values
typeset -i a

a=0;
for files in ${array[@]}
do
cd ~/shell_lib
ls | grep $files
${values[$a]}="$(cksum $files)" 
a=$a+1
done

echo ${values[@]}

OUTPUT


$ ./intarray.sh forall.sh name.sh 
forall.sh
./intarray.sh[12]: =3311936491 251 forall.sh:  not found
name.sh
./intarray.sh[12]: =3294813710 338 name.sh:  not found

The file is there and it has done the cksum, but still it says not found! I can not understand what is wrong! Any insight?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:39:09+00:00Added an answer on June 2, 2026 at 2:39 pm
    ${values[$a]}="$(cksum $files)"
    

    This is almost certainly not what you want. Try:

    values[$a]="$(cksum $files)" 
    

    ${array[index]} refers to the value of the (still empty) array entry, so the original line
    results in the shell trying to execute ="$(cksum $files)".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a bit of a problem. Trying to assign a template variable within a
I'm having a problem when trying to pass an array back to a COM
I'm having a problem trying to run my sql script into oracle using sqlplus.
I am having a problem trying to sort with an XSL file using the
I'm having a problem trying to add a custom HTML5 data attribute to the
I'm having a problem trying to send an array of ints to a .NET
I am having a problem trying to use the prependTo() function in jQuery... for
I'm having a problem trying to format the output on the jQuery UI datepicker.
I'm having a problem trying to create a Javascript function that checks all the
I'm having a problem trying to make eclipse and aspectj work for Dynamic Web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.