![]() |
String manipulation won't work in script but will if extracted
Using Slackware 13.37 w/ bash 4.1.10.
Using the following commands in a bash script fails with: syntax error near unexpected token `}' bash-4.1$ pknt=789 <-----added for interactive mode bash-4.1$ jj="00000$pknt" bash-4.1$ jj=`echo ${jj:(-3)}` <-----error?? bash-4.1$ echo $jj 789 but as U can C it works fine when cut and pasted in interactive mode. Tried as ${jj: -3} but gets same error. Did I leave out some command to tell bash I would use string manipulation or is this a bug? If there is a sad face it is covering ":(" |
Do you mind pasting the code here? It would make debugging easier
|
Are you using
Code:
#!/bin/shCode:
#!/bin/bash |
Quote:
http://www.gnu.org/software/bash/man...OSIX-Mode.html |
Quote:
|
It also works on Slackware64-13.37 using /bin/sh and /bin/bash, but it does not work when using /bin/ash (or in interactive mode using ash). The link wildwizard posted mentions parameter expansion but not *which* uses are valid. Obviously bash doesn't discriminate, but other shells might (see `man ash`, which doesn't list
Code:
${parameter:offset} |
String manipulation won't work in script but will if extracted
willysr, when I went to get that segment of the script I found a missing preceding "if"-- Dah! working too long
Apologies |
| All times are GMT -5. The time now is 09:30 AM. |