We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Filter an Array with Patterns
Filter an Array with Patterns
Sort by
recency
|
146 Discussions
|
Please Login in order to post a comment
readarray -t array echo "${array[@]/*[aA]*/}" | xargs
another approach:
readarray -t array printf '%s\n' "${array[@]}" | grep -Ev "a|A"
here printf prints each array element in a new line, The grep command here filters out 'a' or 'A'
arr=()
while IFS= read -r line do if [[ "line") fi done
echo "${arr[@]}"
arr=() while IFS= read -r line do arr+=( $line) done
ans=() for var in {var:i:1}" == 'a' ]] || [[ "flag == 0 ] then ans+=( $var) fi done
for val in val " done
while read -r q;do echo $q | grep -vi "a" done
correct output is coming, but giving compilation error.
sed '/a/d'
Just deletes every line matching the pattern.