当前位置: 技术问答>linux和unix
Bash中if语句中是命令怎么写?
来源: 互联网 发布时间:2017-05-29
本文导语: cmd="ls|grep -i $1" if [ `"$cmd|wc -l"` -gt 1 ] then echo "More than one package can be found!" for file in $cmd do echo $file done exit fi 在第二行的判断中有错误,不知道如果更改,在线求高手. | cmd="`ls|grep -i $1`" if ...
cmd="ls|grep -i $1"
if [ `"$cmd|wc -l"` -gt 1 ]
then
echo "More than one package can be found!"
for file in $cmd
do
echo $file
done
exit
fi
在第二行的判断中有错误,不知道如果更改,在线求高手.
|
cmd="`ls|grep -i $1`"
if [ `echo "$cmd"|wc -l` -gt 1 ]; then
echo "More than one package can be found!"
for file in `echo "$cmd"`; do
echo $file
done
fi