Created
February 2, 2023 02:44
-
-
Save iHTCboy/adc4fbae7912135325bbfd56d19c2ecd to your computer and use it in GitHub Desktop.
检查 Mach-O 是静态库还是动态库
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 定义用到的变量 | |
project_path="" | |
# 定义读取输入字符的函数 | |
function getProjectPath() { | |
# 输出换行,方便查看 | |
echo "================================================" | |
# 监听输入并且赋值给变量 | |
read -p " Enter project path: " project_path | |
# 如果为空值,从新监听 | |
if test -z "$project_path"; then | |
getProjectPath | |
else | |
read_dir ${project_path} | |
fi | |
} | |
function read_dir(){ | |
for file in `ls $1` #注意此处这是两个反引号,表示运行系统命令 | |
do | |
if [ -d $1"/"$file ] #注意此处之间一定要加上空格,否则会报错 | |
then | |
read_dir $1"/"$file | |
else | |
#在此处处理文件即可 | |
file_path="$1/$file" | |
if `file ${file_path} | grep -q 'Mach-O'` ; then | |
find_world=$(echo `file ${file_path} | grep 'dynamically linked shared library'`) | |
# -n 字符串 字符串的长度不为零则为真 | |
if [ -n "$find_world" ] ; then | |
echo '-----------------------------\n' | |
echo $file | |
echo '是动态库' | |
#echo `file ${file_path}` | |
echo '\n' | |
else | |
echo '-----------------------------\n' | |
echo $file | |
echo '是静态库' | |
#echo `file ${file_path}` | |
echo '\n' | |
fi | |
fi | |
fi | |
done | |
} | |
#读取第一个参数 | |
getProjectPath | |
echo "------- end processing -------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment