美文网首页
shell常用代码

shell常用代码

作者: Joshua520 | 来源:发表于2020-08-06 09:57 被阅读0次

1、免密执行安装插件

echo [password] | sudo -S gem install plist

2、为空判断

if [ -n "$x" ] ; then
   command
else
   exit 1
fi

3、遍历文件获取文件名
文件名称不能带有空格,有空格会获取空格后的名字,现已处理支持带空格的情况。

for element in `ls "$1" | tr " " "\?"`
do
    element=`tr "\?" " " <<<$element`
    dir_or_file="$1"/"$element"
    if [ -d "$dir_or_file" ];then
        var=$( find "$dir_or_file" -name '*.xcodeproj' )
        var1=${var##*/}
        if [ -n "$var1" ];then
            podStr="Pods"
           if [[ $var1 == *$podStr* ]];then
            echo "Pods.xcodeproj"
           else
            #截取.之前的所有字符串
            appname=${var1%.*}
            echo $appname
           fi
        fi
       
    fi
done

带有空格的获取方式,🌰是获取xxx.app这个名字,改签时要用。

var=$( find "$path/ios_resign/Payload" -name '*.app' )
app_name=${var##*/}

4、打包ipa脚本

xcodebuild clean -workspace "${app_name}.xcworkspace" -scheme "${app_name}" -configuration enterprise
xcodebuild archive -workspace "${app_name}.xcworkspace" -scheme "${app_name}" -archivePath "${app_name}.xcarchive" -quiet
xcodebuild -exportArchive -archivePath "${app_name}.xcarchive" -exportPath ipa -exportOptionsPlist "Vigame/ExportOptions.plist"

5、上传fir.im

fir publish file -T "${token}" -Q

6、find命令

keyfile=Images.xcassets
x=$(find filepath -name $keyfile)

7、添加证书

#添加证书和描述文件
security import xx.p12 -k ~/Library/Keychains/login.keychain-db -P [password] -A
open xxx.mobileprovision

8、shell传递参数
如果参数超过10个,后续的参数需要加{}

${10}

相关文章

  • shell常用代码

    1、免密执行安装插件 2、为空判断 3、遍历文件获取文件名文件名称不能带有空格,有空格会获取空格后的名字,现已处理...

  • Shell 常用代码片段

    获取脚本运行目录 或者 解析:dirname命令接受一个文件路径作为参数,返回该路径对应的目录路径。例如我们执行:...

  • spark RDD常用函数/操作

    spark RDD常用函数/操作 文中的代码均可以在spark-shell中运行。 transformations...

  • 常用的shell变量用法d672534acf8d9f548023

    常用的shell变量: $0 Shell本身的文件名, 带有相对路径。(常用于shell中脚本路径切换) $1~$...

  • HBASE SHELL常用命令

    HBASE SHELL常用命令 标签: HBase Shell 1. 进入hbase shell console ...

  • adb命令

    常用非Shell命令:1、adb shell dumpsys activity top2、adb shell du...

  • Shell | 基础知识点实例整理(一)

    写一个简单的Shell脚本 代码如下: 练习使用Shell变量 代码如下: 练习使用Shell的命令行参数 代码如...

  • Shell参考资料

    shell 目录 Shell简介 Shell常用命令 Shell里面的括号 Shell里面的单引号和双引号 She...

  • 整理linux基础命令|2018-10-23

    shell快捷键 | linux 下常用两种脚本 shell - - unix -- Bourne shell b...

  • Linux Shell:Shell循环语句

    摘要:Linux,Shell Shell中常用循环有for,while Shell循环语法结构 (1)for循环语...

网友评论

      本文标题:shell常用代码

      本文链接:https://www.haomeiwen.com/subject/hldnrktx.html