There is a file name as pkg_list
a-1.2b-1.tar.gz
c-2.5b-1.tar.gz
a xx-1.4.txz
a$xx-1.4.txz
中文-3.txz
xx-3.2-2.tar.gz
xxy-1.3.tar.gz
My bash function can input package name like 'xx'
pkg_find() { # <pkg_name> as $1
grep "^$1-[0-9]*" pkg_list
}
pkg_find xx # wish it return xx-3.2-2.tar.gz
I know I can not pass $1 directly into pkg_find, what's the correct method?
[SOLVED] In this case, because $1 is enclosed by double quote, I found even regex meta chars could pass as parameter.