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
|
141 Discussions
|
Please Login in order to post a comment
readarray countries
for country in "country" | grep -v "[aA]" | tr -d '\n'
done
yeah thats all... no clue why people are writing such complex lines of code
Using grep is missing the point of the exercise.
array=() while read line do array+=( ${line}) done
echo ${array[@]}
arr=() for n in "n != *"a"* ]] && [[ $n != "A" ]] then arr+=(${n})
fi done
echo ${arr[@]}