I am getting bad substitution error.
<CODE>
date=20130201_0101 cti_check_date=$(date -d "${date//_/ } - 4 hours" +%Y%m%d_%H50) eval "transfer_${date}_list='20130401_0150'" eval "transfer_${date}_list="${transfer_${date}_list}\n${cti_check_date}"" echo "${transfer_${date}_list}" </CODE> I got the following error: test.sh: line 4: "transfer_${date}_list="${transfer_${date}_list}\n${cti_check_date}"": bad substitution test.sh: line 6: ${${transfer_${date}_list}}: bad substitution Please help me. |
Any help?
|
Anybody there?
|
1. Odd looking code; can you explain what you're trying to do?
2. you don't need eval to assign values 3. use square brackets [ ] for code tags, not < > https://www.linuxquestions.org/quest...do=bbcode#code 4. use 'set -xv' at the top of your code; it'll show you what's going on in detail |
I agree with the above, please explain the purpose of the code as it is completely unclear at present.
|
${transfer_${date}_list} doesn't look valid at all - it looks like a recursive substitution-
The first level is the transfer_${date}_list to get an environment variable.... then to use that to extract its value. If that is what you are trying to do... I think you will have to use an eval to get the final value... |
All times are GMT -5. The time now is 12:47 PM. |