Skip to content

Instantly share code, notes, and snippets.

@hansstimer
Created September 11, 2012 00:55
Show Gist options
  • Save hansstimer/3695166 to your computer and use it in GitHub Desktop.
Save hansstimer/3695166 to your computer and use it in GitHub Desktop.
bash: iterate, and regex example
#!/bin/sh
set -o errexit
foo="a 1a b c d e"
bar="a b d e f g"
for x in $bar
do
if ! [[ "$foo" =~ (^|[[:blank:]])$x([[:blank:]]|$) ]]; then
echo $x
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment