0

I have a variable that points at a file called point.c

I would like to temporarily append "A" to "_SRCS" so I can rename the variable and use it in a function as "SRCS".

A_SRCS=point.c
  
pro="A B"
for x in $pro
    do
    SRCS=${${x}"_SRCS"}
    echo $SRCS #(will point to a function later on..)
    done
Alon212
  • 51
  • 10
  • It's really not clear what you are trying to ask. You can copy the value of one variable into another and you can delete the original, but this makes little sense to want. – tripleee Dec 14 '20 at 10:38
  • I am actually trying to append a variable with a string - "x" being the variable from the for loop and the "_SRCS" as a string – Alon212 Dec 14 '20 at 10:43
  • the end result is that every iteration the variable $SRCS is pointing at another file. I forgot to add that i will have also "B_SRCS" and "C_SRCS" – Alon212 Dec 14 '20 at 10:45
  • Vaguely sounds like the duplicate is correct then. @oguz congrats for the gold badge! – tripleee Dec 14 '20 at 11:03
  • @tripleee Thanks! Not sure if there's a better dupe for this, but I'm sure this has been asked several times before – oguz ismail Dec 14 '20 at 11:12
  • @tripleee - Congrats !!! so i did mange to do this SRCS="${x}_SRCS" but I am not able to use "A_SRCS" as a variable – Alon212 Dec 14 '20 at 11:18
  • Did you notice the `!` for indirection? – tripleee Dec 14 '20 at 11:19
  • YESSSSS got it ! I am a 40y/o musician from TLV doing a career shift due to the corona virus. Help is super appreciated ! – Alon212 Dec 14 '20 at 11:26

0 Answers0