常用的shell语句
发表于
|浏览量:
常用的shell语句
1 | #!/bin/bash |
1 | SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"; |
文章作者: yxibng
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 yxibng!
相关推荐
2023-05-17
oh my zsh prompt 展示当前路径
使用的主题为 1ZSH_THEME="robbyrussell" 修改配置, path ~/.oh-my-zsh/themes/robbyrussell.zsh-theme, 将 %c 替换为 %d 123456789# beforePROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ ) %{$fg[cyan]%}%c%{$reset_color%}"PROMPT+=' $(git_prompt_info)'# afterPROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"PROMPT+=' %{$fg[cyan]%}%d%{$reset_color%} $(git_prompt_info)' 参考: EXPA...
2022-05-11
通过脚本修改xcode pbxproj文件
分析 xcode pbxproj 文件格式 创建一个新的iOS工程demo, 进入工程目录, 找到project.pbxproj。 12345➜ demo git:(main) ✗ lsdemo demo.xcodeproj demoTests demoUITests➜ demo git:(main) ✗ cd demo.xcodeproj➜ demo.xcodeproj git:(main) ✗ lsproject.pbxproj project.xcworkspace xcuserdata 通过code打开看看文件内容。 The Xcode project file is an old-style plist (Next style) based on braces to delimit the hierarchy. The file begins with an explicit encoding information, usually the UTF-8 one. project.pbxproj文件格式是旧式的plis...
2022-11-16
命令行重启iPhone
参考: Any way to reboot a iDevice that is connected to a USB port via terminal (Mac terminal)? 安装libimobiledevice 12brew install libimobiledevice 使用 1idevicediagnostics restart
2022-02-25
Shell 特殊变量
特殊变量$$当前 shell 的进程ID 1$echo $$ 输出当前进程的pid 12➜ ~ echo $$19248 $0 当前脚本的文件名 $n 当前脚本的参数,从1开始 $1第一个参数,$2第二个参数,$n第n个参数 $# 脚本参数的总个数 $* 脚本参数集合,所有的参数被双引号包裹。如果脚本2个参数,$*="$1 $2" $@ 脚本参数集合,每个参数被单独的双引号包裹。如果脚本2个参数,$*="$1" "$2" $? 上个命令的返回值。 $$ 当前shell 的进程ID。 $! The process number of the last background command. 示例 12345678#!/bin/shecho "File Name: $0"echo "First Parameter : $1"echo "Second Parameter : $2"echo "...
2022-02-25
Shell 变量
Shell 变量变量名The name of a variable can contain only letters (a to z or A to Z), numbers ( 0 to 9) or the underscore character ( _). By convention, Unix shell variables will have their names in UPPERCASE. 合法的变量 1234_ALITOKEN_AVAR_1VAR_2 非法变量 12342_VAR-VARIABLEVAR1-VAR2VAR_A! 定义变量1variable_name=variable_value 例如: 1NAME="Zara Ali" shell 允许变量存你想要的任何值, 例如 12VAR1="Zara Ali"VAR2=100 获取变量的值通过在变量前添加$来引用变量 1234#!/bin/shNAME="Zara Ali"echo $NAME 输出 1Zara Ali 只读变量在变量前添...
2022-02-25
Shell 数组
Shell 数组参考: Shell中的数组及其相关操作_杰瑞的专栏-CSDN博客 应用场景: 求数组的长度 元素长度 遍历数组 元素切片 替换 删除 备注: Shell中的数组不像JAVA/C,只能是一维数组, 没有二维数组 数组元素大小无约束,也无需先定义数组的元素个数 索引从0开始 不像JAVA/C等强编程语言,在赋值前必须声明;SHELL只是弱编程语言,可事先声明也可不声明; 用unset来撤销数组,可用unset array_name[i]来删除里面的元素 声明1234declare -a array_name # 声明数组,也可不声明declare -a nums=(1 2 3 4) # 声明数组, 同时赋值unset array_name # 删除数组,撤销数组unset nums[0] # 删除数组中某个元素 定义12345678910111213141516171819#方式一:array_names=(value0valuelvalue2valu...
公告
This is my Blog
