tap_hook
(tap_hook)
1
我写了下面的脚本,但是报错,不知道该怎么写,求大神指导下。
if dpkg -l com.xxx.xxx | grep '^.i' > /dev/null ]; then
echo "installed"
else
echo "not installed"
fi
com.xxx.xxx 代表要查询的包名,报的是这样的错误
./postinst: line 8: : missing `]'
grep: ]: No such file or directory
为了避免你问XY问题,我确认一下,你的目的是判断某个package是否安装,还是要指定依赖package,还是要指定冲突package?
tap_hook
(tap_hook)
3
我是检测自己的另外一个package是否被用户安装,根据安装情况做些处理,不是检查依赖包。
tap_hook
(tap_hook)
4
自己解答吧,
export installed=$(dpkg -l com.xxx.xxx | grep '^.i')
# echo $installed
if $installed == 0 ]]; then
echo "not installed"
else
echo "installed"
fi