从A文件取出前两列 和另一个文件匹配 打印出匹配到的行 from=$1 compare=$2 tofile=$3 f1s=( $(cat $from |awk -F ‘\t‘ ‘{print $1}‘) ) f2s=( $(cat $from |awk -F ‘\t‘ ‘{print $2}‘) ) #for i in `seq 0 ${#f1s[@]}`; do echo ${f1s[$i]} ; done; for i in `seq 0 ${#f1s[@]}` do if [[ ‘‘ == `echo ${f1s[$i]} | sed ‘s/^ //;s/ $//‘` ]] then continue elif [ 0 -lt `grep ${f1s[$i]} $compare | grep ${f2s[$i]} |wc -l` ] then echo ${f1s[$i]} ${f2s[$i]} >> $tofile fi done exit 0
时间: 2024-10-05 22:47:29