问题
#!/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?
回答1:
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?
来源:https://stackoverflow.com/questions/43416413/inserting-variable-into-sh-script-command