主要awk 基本运用
!/bin/bash
if [ $# -ne 1 ];then
echo "$0 <dir>"
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)文章来源地址https://www.toymoban.com/news/detail-706428.html
文章来源:https://www.toymoban.com/news/detail-706428.html
到了这里,关于Shell脚本-awk运用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!