Last active
October 25, 2017 08:09
-
-
Save Loveforkeeps/a9d0d9d9a94e71189253b44cf3dd9b3a to your computer and use it in GitHub Desktop.
Ubuntu和Mac平台,PDNS数据处理,样例数据:ali1.rabbitpre.com.|117.169.81.237:27|117.169.81.219:29|117.169.81.217:25|117.169.81.236:20|117.169.81.218:38|223.82.136.179:9|223.82.136.174:8|223.82.136.178:10|223.82.136.177:12|223.82.136.176:14|223.82.136.175:15|117.169.81.221:30|223.82.136.228:15|117.169.81.220:32|223.82.136.229:18|117.169.81.222:25|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Mac 上 readlink -f 无法使用的替代代码 | |
TARGET_FILE=$0 | |
cd `dirname $TARGET_FILE` | |
TARGET_FILE=`basename $TARGET_FILE` | |
while [ -L "$TARGET_FILE" ] | |
do | |
TARGET_FILE=`readlink $TARGET_FILE` | |
cd `dirname $TARGET_FILE` | |
TARGET_FILE=`basename $TARGET_FILE` | |
echo $TARGET_FILE | |
done | |
PHYS_DIR=`pwd -P` | |
PWD=`dirname $PHYS_DIR/$TARGET_FILE`/domainArchive/ | |
echo $PWD | |
mkdir -p $PWD | |
# 以上为了协调Mac上readlink -f无法使用,与脚本功能无关 | |
awk -F '\\.\\|' '{print $1}' $1 > ${PWD}${1: -12:8}Domain.txt | |
if [ `echo $?` -eq 0 ];then | |
echo "${1: -12:8}Domain.txt saved to domainArichive/ succeed!" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Mac 上 readlink -f 无法使用的替代代码 | |
TARGET_FILE=$0 | |
cd `dirname $TARGET_FILE` | |
TARGET_FILE=`basename $TARGET_FILE` | |
while [ -L "$TARGET_FILE" ] | |
do | |
TARGET_FILE=`readlink $TARGET_FILE` | |
cd `dirname $TARGET_FILE` | |
TARGET_FILE=`basename $TARGET_FILE` | |
echo $TARGET_FILE | |
done | |
PHYS_DIR=`pwd -P` | |
PWD=`dirname $PHYS_DIR/$TARGET_FILE`/ipArchive/ | |
echo $PWD | |
mkdir -p $PWD | |
# echo `date`"Split IP content" | |
awk -F '\\.\\|' '{print $2}' $1 > ${PWD}${1: -12:8}IPDup.txt | |
# echo `date`"Split IP item" | |
# Mac | |
sed -i '.bak' 's/:[0-9]\{1,\}|/\'$'\n''/g' ${PWD}${1: -12:8}IPDup.txt | |
# Ubuntu | |
# sed -i 's/:[0-9]\{1,\}|/\'$'\n''/g' ${PWD}${1: -12:8}IPDup.txt | |
# echo `date`"delete Blank" | |
# Mac | |
sed -i '.bak' '/^$/d' ${PWD}${1: -12:8}IPDup.txt | |
# Ubuntu | |
# sed -i '/^$/d' ${PWD}${1: -12:8}IPDup.txt | |
if [ `echo $?` -eq 0 ];then | |
# echo `date`"deduplicate" | |
awk '!a[$0]++' ${PWD}${1: -12:8}IPDup.txt > ${PWD}${1: -12:8}IP.txt | |
rm ${PWD}${1: -12:8}IPDup* | |
echo "${1: -12:8}IP.txt deduplicate saved to ipArchive/ succeed!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment