5
#!/bin/sh -f

set proj_dir="OutputDir"
for projname in lib proj1 proj2
do
    mv ./scripts/$projname_BYTECODE ./$proj_dir/scripts/$projname
done

A very simple example of what is not working well for me. $projname_BYTECODE is being interpreted as a variable name but _BYTECODE is actually part of the folder name. Suggestions?

5
  • 2
    ${projname}_BYTECODE? Commented Apr 14, 2017 at 17:37
  • You know, I "tried" that, but the syntax highlighting on gedit said it was still one variable so I did not actually try it. That does seem to have worked, though. You should answer the question. Commented Apr 14, 2017 at 17:41
  • 2
    As an aside; you've got some quoting bugs still present -- shellcheck.net will catch them. Commented Apr 14, 2017 at 17:53
  • 1
    set doesn't do what you think it does. Commented Apr 14, 2017 at 18:18
  • Yeah, I realized I put that in there accidentally when making this post. My script did not have that but copying&pasting was not working from my Linux VM at the time. So when I was typing it up, I mixed in some Tcl/Tk that I am unfortunately learning recently. Commented Apr 15, 2017 at 18:02

1 Answer 1

4

Use ${X} instead of $X, so in your example ${projname}_BYTECODE should do the trick. Have a look at this question for more information: When do we need curly braces in variables using Bash?

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.