答案1
和zsh
:
#! /bin/zsh -
words=(foobar foobarbaz STRING)
strings=(fbr STRN xyz)
vowels=aeiouAEIOU # adjust as needed
typeset -A matches=()
for word ($words) {
word_without_vowels=${word//[$vowels]}
for string ($strings)
if [[ $word_without_vowels = $string* ]] matches[$string]+=" $word"
}
for string ($strings)
if (( $+matches[$string] )) print -r -- "$string:$matches[$string]"
给出:
fbr: foobar foobarbaz
STRN: STRING