package.sh
shell
#!/bin/bash for i in `cat $1` do echo $i >> result dpkg -l | grep $i | sed -n 1p > tmp //awk讀出第五列之後的全部數據 awk '{for(i=5;i<=NF;i++) printf("%s ",$i);print ""}' tmp >> result //將腳本的錯誤內容重定向到文件中 sudo dpkg --purge $i >> result 2&1 if [$? == 0] then echo "無包依賴" >>result fi echo "----------------------------------------------" >> result done echo "to the end " exit 0
hello.cbash
glibc
code
libxml
xml
...
it
執行腳本:class
sudo bash package.sh hello awk
輸出結果:sed
包名
grep
包的做用
數據
包的依賴關係
推薦
http://coolshell.cn/?s=shell