Last active
December 11, 2015 14:49
-
-
Save riywo/4616862 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in a aaa bbb abc abcd abcafa ab; do echo $i | grep -E '^a([^(bc)].+||b|bc.+)$' || echo "skip $i"; done | |
a | |
aaa | |
skip bbb | |
skip abc | |
abcd | |
abcafa | |
ab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
grep の -v を使うことが、許されるなら正規表現がちょっとだけシンプルになりそうですね。
for i in a aaa bbb abc abcd abcafa ab; do echo$i | grep -Ev '^(abc|[^a]+)$ ' || echo "skip $i"; done