如题所述
第1个回答 2018-05-28
list1=('~' '!' '@' '#' '$')str="ex@mple"spec_str=$(echo ${list1[*]} | sed 's/\ //g')printf "$str" | awk -v spec_str=$spec_str '{ for (i = 1; i <= length(spec_str); ++i) { pos = index($0, substr(spec_str, i, 1)) if (pos != 0) { printf "include char %s at %s\n", substr(spec_str, i, 1), pos exit } }}'
输出如下,具体需求你自己根据需要调整:
include char @ at 3本回答被网友采纳
输出如下,具体需求你自己根据需要调整:
include char @ at 3本回答被网友采纳