您的位置:首页 > 运维架构 > Shell

excel中的某一列,其中有重复,怎么查找?(shell命令)

2014-09-17 15:05 323 查看
方法一:

假设excel中的数据如图所示,我们要检测error number是否有重复

Error NumberError Name
E1223261VsmServiceUnavailable
E1232141VsmHostNotFound
将error number与 error name 两列复制到ubuntu下的一个文件file。

[root@jiyou-test-controller tmp]# cat file | awk '{print $1}' | sort > /tmp/ret

将file的第一行显示,并排序

[root@jiyou-test-controller tmp]# cat file | awk '{print $1}' | sort -u > /tmp/res

将file的第一行显示,并排序,并删除重复项

[root@jiyou-test-controller tmp]# diff /tmp/ret /tmp/res

6d5

< E0001225

53d51

< E0400004

发现有两个error number 有重复,再到excel中查找error number即可。

方法二:

可使用 excel函数: countif 。

可参见博客http://www.360doc.com/content/11/1223/14/701163_174474562.shtml

我先在"error number"(列A)后插入了一列(列B),在B2单元格输入公式=IF(COUNTIF($A$2:A2,A2)>1,"duplicate")。

然后将鼠标放在单元格右下角,便黑色十字后,向下拖动,扩展到真个列B。结果如下:

E0001225duplicateMonitorException
E0001229FALSENoValidHost
E0400003FALSEAddGlobalToCephConfFailed
E0400004FALSEAddMdsToCephConfFailed
E0400004duplicateAddMonToCephConfFailed
这样就找到了重复的列。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: