I am writing a script that prints arguments starting with a vowel and end in a digit
Example : ./script Alex1GB0 Bud1GG0 Ethan8DC0 Chad5XZ7d
The output should be
Alex1GB0 Ethan8DC0
This is what I have tried so far
#!/bin/bash
for x in $*; do
o=$(echo $x | grep '\<[AEIOUaeiou]...[0-9].\>')
if[$? -eq 0]; then
echo $o
fi
done
exit 0
It doesn’t work ; What should I change?
There is nothing like ellipsis (
...) in bash. Instead, use.*. Also, the dot after[0-9]means there is something after the digit, which is against the specification.In fact, there is no need to run a subshell and
grep, when we have pattern matching: