1

I am currently trying to make a variable name that would consist of another variable

while [ "$countf" -le 9 ]; do
                    vname=$( echo fcp"$countf" )
                    $vname=$( awk -F, -vs="\$fc$countf" '{for (i=1;i<=NF;i++)if($i~"^"s"$"){print i;exit;}}{print "not found"}' <<< $first_line )
                    countf=$(( countf + 1 ))
            done

although when I go to execute the the script that includes the code, something along the lines of the following is outputted:

fcp1=not: command not found

fcp1 being the content of the vname variable. I've tried several different solutions but have not gotten anything to work yet as of right now, if someone could point out what I am doing wrong though I would really appreciate it, thanks.

2
  • 1
    why do you need this? Why don't you just call it p1p2 or directly cat1? Commented Nov 19, 2012 at 21:13
  • Repeat of question stackoverflow.com/questions/13462936/… by same user, just 1 hour ago? Commented Nov 20, 2012 at 5:38

1 Answer 1

2

try this:

eval cat$p2="something"

without the quotes around the variable name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.