paulvand
paulvand

Reputation: 31

bash script doesn't act like shell

Here is my script:

#!/bin/bash

x="aabcaa"
y=${x##*(a)}
echo $y

It outputs aabcaa when I expect bcaa.

When I try the same commands on a bash shell (got with bash command from zsh shell), everything works as I want. I checked the version with bash --version and /bin/bash --version. Obviously, the two commands output the same thing. The unexpected behavior of the script is the same in a zsh shell and in a bash shell.

What could be wrong?

Upvotes: 1

Views: 123

Answers (0)

Related Questions