繁琐的事情应该工具化

最近着实被恶心到了,开始统计所有第三方库的版本信息,公司十几个项目都要看,要吐了。

然后就想有没有什么简单的方法呢,工具化。

日志格式大概是这样的:


 1065 17:02:19  (cd /home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/curl-7.74.0; chmod 777 configure; rm -f include/curl/curlbuild.h;./configure --without-libidn --without-zlib --without-librtmp --disable-manual --with-ssl=/home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/openssl-1.1.1n --disable-ldap --disable-rtsp --disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap --disable-pop3 --disable-smtp --disabl      e-telnet --disable-tftp --disable-libcurl-option --enable-shared=no CPPFLAGS="-I/home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/openssl-1.1.1n/include" LDFLAGS="-L/home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/openssl-1.1.1n";make;)

想了想,我们只要看vendors后面的值,所以来一发小工具还是可以的

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const string key = "Vendors";
void show(std::string str)
{
    std::size_t found = str.find(key);
    while (found!=std::string::npos)
    {
        found += key.size();//to key last
        found ++;//to next val
        auto found_end =str.find_first_of("/",found);//to next split char
        if(found_end == std::string::npos)
                break;
        if(found_end - found  > 2)
                std::cout<<str.substr(found,found_end - found)<<std::endl;
        found = str.find(key, found_end + 1);
    }

}

int main(int argc, char** argv)
{
    fstream f("a");
    while(!f.eof())
    {
            std::string str;
            f>>str;
            /* cout<<"file data"<<tmp<<endl; */

            show(str);

    }
    return 1;
}

最后就是我们熟悉的管道命令

./a.out |sort|uniq

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值