Paddy Landau
October 5th, 2009, 04:29 PM
I'm having a big problem with pattern matching in Bash.
Consider the following two lines, which I type into a terminal.
zn='2560x1024'
echo ${zn//+([[:digit:]])/} # Remove all digitsThe output is a single 'x', which is what I expect.
However, if I copy those exact lines into a script, as follows...
#!/bin/bash
zn='2560x1024'
echo ${zn//+([[:digit:]])/} # Remove all digitsThen the output from the script is '2560x1024'.
Why the difference?
Consider the following two lines, which I type into a terminal.
zn='2560x1024'
echo ${zn//+([[:digit:]])/} # Remove all digitsThe output is a single 'x', which is what I expect.
However, if I copy those exact lines into a script, as follows...
#!/bin/bash
zn='2560x1024'
echo ${zn//+([[:digit:]])/} # Remove all digitsThen the output from the script is '2560x1024'.
Why the difference?