https://www.cnblogs.com/ev-zhk/p/4277023.html
-
文件相关
(1) 拷贝cp fromA toB
(2) 重命名mv oldA newA
(3) 删除文件rm fileA
(4) 删除文件夹rm -rf folderA
(5) strings xxxx.a |grep funcA -
查看库xxxx.a里是否有funcA的声明和实现
nm -m xxxx.a | grep methodName
nm -a /Users/xxxx/SourceCode/Developer/5x2/Bin/iOS/libtp.a | grep xxx_verify U _xxx_verify_clean_request
U 表示 Undefined 函数只有声明但没有定义
0000000000000070 T _zoom_verify_clean_request
T表示有实现 -
逐行查找替换 文件中的字符串 sed
https://www.cnblogs.com/ev-zhk/p/4277023.html
sed -i '' 's/searched_string/repalaced_string/g' fromFileA
替换文件fromFileA文中的searched_string为replaced_string,replaced_string为空时,表示直接删掉。Mac使用时需前面加一对单引号"
echo 可以简单查找裁剪字符串
source_string="asfdadfaxxxxadfjjjj"
echo ${source_string%xxxx*} // 在source_string中% 从后往前查找xxxx,找到第一个匹配的后删掉右边的值 %% 找到最后一个
echo ${source_string#*xxxx} // #从前往后查找xxxx,找到第一个匹配的后删掉左边的 ## 找到最后一个
- 2 &> 1
https://blog.csdn.net/zhaominpro/article/details/82630528 - grep
(1) 查找文件是否包含某个字符串
client_config_path=$WORKSPACE/common/include/buildtime_client_config.h
macro="#define ENABLE_ZAPP"
search_result=`grep "${macro}" ${client_config_path}`
if [ $? -ne '0' ]; then
echo "Not find macro ${macro} in ${client_config_path}, add one in the end"
echo $macro >> $client_config_path
fi
(2) 遍历某文件夹(非递归遍历) && 字符串是否包含子串 && 某个.a是否包含函数实现
libs_path=$WORKSPACE/Bin/iOS/
for file in `ls $libs_path` # 遍历文件夹
do
if [[ $file =~ ".a" ]] #include this substring , 查看文件名是否是".a"后缀
then
# check zoom_verify function in $libs_path/$file
echo "-----> $file"
nm -a $libs_path/$file | grep zoom_verify # 查看文件是否有 zoom_verify的声明(U)或实现(T)
fi
if [[ $dependencies_libs_list =~ $file ]] #include this substring
then
rm -rf $libs_path/$file # remove
fi
done
- 文件、文件夹是否存在
if [ ! -f "$file_path" ]; then
fi
if [ ! -d "$folder_path" ]; then
fi
网友评论