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
|
154 Discussions
|
Please Login in order to post a comment
This one line worked very well
sed -e '/a/d' -e '/A/d'
This one line worked very well
sed -e '/a/d' -e '/A/d'
a=($(cat))
p=(${a[@]/* a */})
echo ${p[@]}
i set the input as array a
then i edited array a into a new array p, removing all instances of "a", as well as the characters before and after "a". (remove the spaces in * a *)
then i used echo to show me the new array p
does this one make sense
This was my solution> #!/bin/bash
i=10 i2=0 array1=()
while ((i));do read dato array1=("dato") #echo "((i2+1)) done
declare -a patter=(${array1[@]/[a-zA-Z]a/})
echo ${patter[@]}
Mostly simple, but not the correct way