zoukankan      html  css  js  c++  java
  • 腾讯一shell试题.

    腾讯一shell试题.

                假设qq.tel文件内容:

                  12334:13510014336

                  12345:12334555666

                  12334:12343453453

                  12099:13598989899

                  12334:12345454545

                  12099:12343454544

                分类如下:

                  [12334]

                      13510014336

                      12343453453

                      ...........

                  [12099]

                      13598989899

                      12343454544

                      ............

              实现如下:

                                    sort  qq.tel| awk  -F':'   '{if(tmp!=$1)   {tmp=$1;print "["tmp"]";}  print $2;}'  #tmp可以换成其他字符           判断tmp是否不等于   不等于就把$1赋值给tmp      打印tmp的值"tmp“   打印$2 

    sort 11.txt |awk '{if(tmp!=$1){tmp=$1;print "["tmp"]"}print $2}'

    找出两个文件中一样的qq号

    1 #!/bin/bash
      2 for string1 in `cat a.txt`;do
      3     for string2 in `cat b.txt`;do
      4         if [ "$string1" == "$string2" ];then
      5             echo $string1
      6         fi
      7     done
      8 done     

  • 相关阅读:
    第一章epoll
    sk_buff结构--转载
    邻居子系统1.5 neigh output
    netfilter内核态与用户态 通信 之 sockopt
    邻居子系统1.4
    邻居子系统 1.3
    邻居子系统 1.2
    邻居子系统 1.1
    linux 内核 tasklets 原理以及工作队列
    linux 内核 同步原理
  • 原文地址:https://www.cnblogs.com/hanxing/p/4230898.html
Copyright © 2011-2022 走看看