Skip to content

Instantly share code, notes, and snippets.

@andras-tim
Last active April 11, 2017 14:14
Show Gist options
  • Save andras-tim/909aa427343aede851bc6622cf91d628 to your computer and use it in GitHub Desktop.
Save andras-tim/909aa427343aede851bc6622cf91d628 to your computer and use it in GitHub Desktop.
code snipet for comment on http://stackoverflow.com/a/43346098/1108919
#!/bin/bash
set -eufo pipefail
shopt -s extglob
patterns=''
for pattern in "$@"; do
patterns+="${pattern}|"
done
while read -r i; do
if [[ "$i" == @(${patterns%|}) ]]; then
echo "$i"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment