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"` != ""