!/bin/bash
if [ $# -ne 1 ];then
echo "$0 "
exit 1
fi
bcpdir="$1"
if [ ! -d "$bcpdir" ];then
echo "invalid dir input"
exit 1
fi
TOPDIR=`pwd`
LOG="$TOPDIR"/log_`date +%s`.txt
echo "start ..." >>"$LOG"
date "+%Y/%m/%d %H:%M:%S" >>"$LOG"
find "$bcpdir"/ -type f -name "one-three-seven-*.zip" >"$LOG"
rm -f collector_id.txt
find "$bcpdir"/ -type f -name "one-three-seven-*.zip" |while read line
do
echo "$line"
b-c-p_010jibenxinxi100=$(unzip -l "$line" |grep "jibenxinxi.txt" |awk '{print $NF}')
#echo "$bcp_010100"
unzip "$line" "$b-c-p_010jibenxinxi100" 1>/dev/null 2>&1
if [ -s "$b-c-p_010jibenxinxi100" ];then
cat "$b-c-p_010jibenxinxi100" |awk -F"\t" '{print $1}' >> collector_id.txt
rm -f "$b-c-p_010jibenxinxi100"
fi
done
echo "all saved to collector_id.txt"
cat collector_id.txt
更多awk请参考](https://yebd1h.smartapps.cn/pages/blog/index?blogId=124650232&_swebfr=1&_swebFromHost=bdlite)