标签:pip 依赖 cat bash lin ash 版本 == while
#!/bin/env/bash
find . -type f |grep py|xargs grep -E ‘^from|^import‘| awk -F "py:" {‘print $2‘}|sort|uniq>res0.log
sed -i ‘s/from/import/g‘ res0.log
cat res0.log |awk -F "import " {‘print $2‘}|awk -F ‘.‘ {‘print $1‘}> res1.log
sed -i "s/,[ ]*/\n/g" res1.log
sed -i “s/\s/\n/g" res1.log
cat res1.log|sort|uniq |while read line
do
echo `pip list|grep $line` >> res2.log
done
awk NF res2.log > res3.log
sed -i ‘s/ (/==/g‘ res3.log
sed -i ‘s/)//g‘ res3.log
sed -i "s# #\n#g" res3.log
sort res3.log|uniq >requests.txt
rm /tmp/res*
检测Python项目依赖包以及版本
标签:pip 依赖 cat bash lin ash 版本 == while
原文地址:http://www.cnblogs.com/nixiaocang/p/7502680.html