Reputation: 2581
Is it possible to exclude a domain from a grep
? What I have tried below doesn't seem to work.
ls -l /var/www/folder | grep -E -o --exclude-dir="@somedomain.com" --color "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b">>test.txt
Upvotes: 1
Views: 64
Reputation: 1000
-l /var/www/folder | grep --invert-match "@somedomain.com" | grep -E -o --color "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+\b">>test.txt
Upvotes: 1
Reputation: 17674
how about this
ls -l /var/www/folder | grep -v "@somedomain.com"
test case:
$ mkdir -p /tmp/test && cd $_
$ touch {a,b,c,d}@domain.com
$ touch {e,f}@somedomain.com
$ ls
domain.com [email protected] [email protected] [email protected] [email protected] [email protected]
$ ls -1 | grep -v "@somedomain.com"
[email protected]
[email protected]
[email protected]
[email protected]
Here is what the man page says for -v
-v, --invert-match Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)
Upvotes: 2