开发者

Greping folder names but exluding "@domain.com"

Is it possible to exclude a d开发者_开发百科omain 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


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  b@domain.com  c@domain.com  d@domain.com  e@somedomain.com  f@somedomain.com
$ ls -1 | grep -v "@somedomain.com"
a@domain.com
b@domain.com
c@domain.com
d@domain.com

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.)


-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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜