for读取整行数据

secur1ty@localhost:/tmp/test2$ cat test.txt
adduser 3.118
apt 2.2.4
apt-transport-https 2.2.4
base-files 11.1+deb11u3
base-passwd 3.5.51
bash 5.1-2+b3
secur1ty@localhost:/tmp/test2$ cat
a.txt getsrcinfo.sh test.txt
secur1ty@localhost:/tmp/test2$ cat getsrcinfo.sh

! /bin/bash -x

IFS=$'\n\n' ###以整行读取

for i in cat test.txt
do
pkgname=$(echo $i | awk '{print $1 } ')
pkgversion=$(echo $i | awk '{print $2}')
apt source "$pkgname" &> /dev/null
rm -rf *.dsc .tar. .diff
srcall=$(ls | grep -v test.txt | grep -v getsrcinfo.sh | grep -v a.txt)
srcname=$(echo "$srcall"|awk -F '-[0-9]' '{print $1}')
srcversion=$(echo "$srcall"| sed "s/""$srcname""//g" | sed "s/-//g")
echo "$pkgname|$pkgversion|$srcname|$srcversion "
echo "$pkgname|$pkgversion|$srcname|$srcversion " >> /tmp/test2/a.txt
rm -rf "$srcall"
done

cat a.txt

posted @ 2023-02-08 14:37  雨曼晴川  阅读(33)  评论(0编辑  收藏  举报