linux下binary文件,Linux查找二进制文件(Linux Find Binary File)

Linux查找二进制文件(Linux Find Binary File)

我试图在Linux系统中使用类似下面的方法找到二进制文件:

if [ -f `which $1` ] then

echo "File Found"

else

echo "File not Found"

fi

虽然代码工作正常,但问题是“哪个”将返回一个空操作符,BASH将其解释为存在的某个文件,以便始终找到文件。 任何建议都会很棒。

谢谢

I am attempting to find a binary file in a Linux system using something like this:

if [ -f `which $1` ] then

echo "File Found"

else

echo "File not Found"

fi

while the code works fine the problem is "which" will return a null operator which BASH interprets as something existing so a file always comes back found. Any suggestions would be great.

Thanks

原文:https://stackoverflow.com/questions/9014262

更新时间:2019-10-12 09:53

最满意答案

if [ `which "$1"` != ""

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值