本文介绍了结合就像在bash术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有域名与一些的时候,他们发生的电子邮件文件集合中的文本文件的列表。例如:

  598 aol.com
  1 aOL.COM
  4 Aol.com
  1 AOl.com
  6 AOL.com
 39 AOL.COM

有分别发送给aol.com 598电子邮件和1发送到aOL.COM等。我在想,如果有在bash的方式结合起来aol.com和aOL.COM和所有其他别名,因为它们实际上是一回事。任何帮助将大大AP preciated!

这是code那产生的输出行:

 的grep -E -o -r\\ B〔A-ZA-Z0-9 ._%+  - ] + @ [A-ZA-Z0-9 .-] + \\ [A-ZA-Z] {2,6} \\ b与$ ARCHIVE | SEDs/.*@//|排序| uniq的-c> TEMP2


解决方案

添加 -i - 忽略大小写)标志在单行的 uniq的命令:

 的grep -E -o -r\\ B〔A-ZA-Z0-9 ._%+  - ] + @ [A-ZA-Z0-9 .-] + \\ [A-ZA-Z] {2,6} \\ b与$ ARCHIVE \\
    | SEDs/.*@//'\\
    |排序\\
    | uniq的-ic> TEMP2

uniq的手册页:

-i
--ignore情况
    比较行的时候忽略大小写的区别。

I have a list of domain names in a text file with a number of times they occur in a collection of email files. For example:

 598 aol.com
  1 aOL.COM
  4 Aol.com
  1 AOl.com
  6 AOL.com
 39 AOL.COM

There were 598 emails sent to aol.com and 1 sent to aOL.COM and so on. I was wondering if there was a way in bash to combine aol.com and aOL.COM and all the other aliases since they are in fact the same thing. Any help would be greatly appreciated!

This is the line of code that produced that output:

grep -E -o -r "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" $ARCHIVE | sed 's/.*@//' | sort | uniq -c > temp2
解决方案

Add a -i (--ignore-case) flag to the uniq command in your one-liner:

grep -E -o -r "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" $ARCHIVE \
    | sed 's/.*@//' \
    | sort \
    | uniq -ic > temp2

From the uniq man page:

-i
--ignore-case
    Ignore differences in case when comparing lines.

这篇关于结合就像在bash术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:19