shell
power_to_go
http://stardustman.github.io
公众号: ThoughtRefactor
展开
-
aws-cli major version 判断
使用了两个版本的 cli 需要特别处理 AWS_CLI_MAJOR_VERSION=$(aws --version 2>&1 | cut -d " " -f1 | cut -d "/" -f2 | cut -d "." -f1) if [ "$AWS_CLI_MAJOR_VERSION" = "1" ]; then echo "aws-cli verion is 1" $(aws ecr get-login --no-include-email --region cn-nor原创 2022-01-28 14:07:44 · 433 阅读 · 0 评论 -
redis 集群分配 slot (error) ERR Invalid or out of range slot 错误
什么错误? 127.0.0.1:6379> cluster addslots {0..5461} (error) ERR Invalid or out of range slot 错误原因 { }在 bash 中是 brace explansion(括号展开) 的意思。 如 mkdir redis-637{4,5,6} 会生成 redis-6374、redis-6375、redis-6376 这 3 个文件夹 使用 seq 解决 > redis-cli -h 127.0.0.1 clus原创 2020-12-30 16:41:48 · 2687 阅读 · 1 评论 -
Shell 脚本 2>&1 是咋回事?
I/O redirection standard output root@aliyun:~# cat foo bar # 标准输出流默认绑定的是显示器 root@aliyun:~# cat foo > output.txt #把标准输出流重定向到 output.txt 这个文件,不在屏幕上显示。 root@aliyun:~# cat output.txt bar standard error root@aliyun:~# cat nonexist.txt > output.txt cat:原创 2020-09-08 09:53:16 · 295 阅读 · 0 评论 -
shell-login-session-环境设置流程
shell 登陆型 session, 也就是需要输入 user name 和 password 的 session。 起因:最近在看 zookeeper bin 下的一系列 shell 脚本。发现还真有好多东西值得琢磨的。 login shell 使用哪些配置文件? 一定会使用 /etc/profile 和 /etc/profile.d(这个文件夹有一系列 shell 脚本) 如上图一共有三种情况: 当前用户 Home 目录找到了 .bash_profile,至此结束。不会执行 2 或者 3。找不到 .原创 2020-05-29 22:40:19 · 421 阅读 · 0 评论 -
shell-bash-directory-stack
change directory cd - 切换到上一个目录。 directory stack 目录堆栈默认值有当前目录。 pushd pushd dirpath 将目录 push 到目录栈,并切换到该目录。 栈顶到栈底编号从 0 开始。 栈底到栈顶编号从 -0 开始。 pushd +2 将从栈顶开始编号为 2 的 directory path 移到栈顶 pushd -2 将从栈底开始编号为 -2 的 directory path 移到栈顶 popd popd 将目录栈顶元素出栈。并切换到栈顶目录。 p原创 2020-05-23 12:50:21 · 237 阅读 · 0 评论 -
shell & sed
Shell算术运算 1. let c=$A+$B 2. c=$[$A+$B] 3. c=$(($A+$B)) 4. expr 表达式中要有空格,oprand opcode 命令引用 c=`expr $A + $B` 程序: 执行结果 执行状态结果 程序返回0 执行成功,非零出错 uid=0(root) gid=0(root) groups=0(root) exit:退出脚本 if 0...原创 2019-03-28 20:22:41 · 98 阅读 · 0 评论