Linux hand-crafted scripts (Help colleagues with Excel report problems) optimized edition

Source: Internet
Author: User

yesterday to help colleagues write scripts, because only realized the basic function did not consider too many other, colleague feedback run very slowly, because of time reasons did not consider processing big data, the results did not pass the test of Big data, the program ran 72 minutes before the results 650) this.width=650 ; "Src=" Http://img.baidu.com/hi/jx2/j_0013.gif "alt=" J_0013.gif "/>:


650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9F/5D/wKioL1mbxFbxTAFHAAAVG6AC2g8878.png "title=" 111. PNG "alt=" Wkiol1mbxfbxtafhaaavg6ac2g8878.png "/>

So today we've made some optimizations and tweaks to the code:


#!/bin/bash
# Design by Jerry_ Jiang (Copyright (c) 2011-2019)
RM baogao2.txt Baogao.txt baobiao.txt c.txt jxip.txt tmp.ym 1&>/dev/null
For i in ' cat-a a.txt '
Do
La= ' echo $i |cut-d "^"-f1 "
lb= ' grep $la b.txt|cat-a |cut-d "^"-f1 "

If ["$la" = = "$lb"]
Then
Continue
Else
Echo $la >>c.txt
Continue
Fi
Done

For line in ' Cat-a c.txt '
Do
Ym= ' echo $line |cut-d "$"-f1 '
ip= ' nslookup $ym-timeout=0.01 |grep "Address:" |head-n 1|awk ' {print $} '
echo "$ym" "$ip" >>jxip.txt
Done
For line in ' Cat-a ip.txt '
Do
Ip= ' echo $line |cut-d "^"-f1 "
grep $ip jxip.txt >>baobiao.txt
Done
Cat Baobiao.txt |sort|uniq >baobiao2.txt
awk ' begin{print ' domain IP address '} {print$1 ' "$ baobiao2.txt} ' >baogao.txt

The final output of the script is Baogao.txt file, other files for the program to temporarily generate files, reserved is the wrong, listen to colleagues say there are special circumstances, so keep the data prepared.

listening to colleagues said he spent one hours a day to repeat the work, so wrote this script, the script basically implemented its requirements, the script there are many improvements and optimizations in place, more advice.

Optimized Big Data Test effect: 650) this.width=650; "src=" Http://img.baidu.com/hi/tsj/t_0023.gif "alt=" T_0023.gif "/>

650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M02/00/AD/wKiom1mbxUPjMoXmAABo9UswXwg050.jpg "title=" 3333. JPG "alt=" Wkiom1mbxupjmoxmaabo9uswxwg050.jpg "/>


This article comes from "on the road ... Recover lost Memory "blog, declined reprint!"

Linux hand-crafted scripts (Help colleagues with Excel report problems) optimized edition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.