前言:在编写sh脚本的时候,发现使用read命令和预期的效果不一样,,因为shell用的是zsh,查了一下发现bash和zsh中read命令的用法有些区别,这里记录一下。 读取字符 从标准输入中读取一个或多个字符 bash: read -n num input zsh: read -k num in
read 在 zsh 和 bash 下的不同 平常我都把 zsh 当 bash 用,但不实际遇到不兼容的问题我还注意不到这个区别,这里我遇到的就是read这个命令在 zsh 和 bash 下是不同的。 缘起 起因是我在脚本里写的两个命令同时都用了read,区别在于一个是封装在 bash 脚本里的,另一个是封装成 zsh 函数。因而当我使用-...
但如果是处理一个文本文件的大量内容等场景,用 sed、grep 等外部命令处理通常要比用 zsh 直接写(比如在一个循环里 read 后处理)要高,因为这种场景进程的启动时间基本可以忽略不计,而 sed、grep 等程序是用 c 写的,性能要比 zsh 脚本高不少。字符串定义:% str=text# 带空格或者某些其他特殊字符的情况需要用...
2.8k line README.md 50k+ LOC 1 line install Prerequisites If you're on a Mac, the zsh that comes with it is usually pretty stale. You can use brew install zsh to update it. Many of the themes here use special glyphs for things like displaying a branch icon. You'll need to ...
Make sure to read it to get the most out of Zinit. Install Automatic The easiest way to install Zinit is to execute: bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)" This will install Zinit ...
"locali=1whileread-r line;doecho"$i.$line"((i++))done<<<"$instances"# 提示用户选择localinstance_numberread-p"请输入实例编号以通过 SSM 连接: "instance_number# 获取实例 IDlocalinstance_id=$(echo"$instances"| sed -n"${instance_number}p"| awk'{print $1}')if[[ -z"$instance_id"...
# Make it read-only. Can't combine this with the previous line when POSIX_BUILTINS may be set.typeset -r ret # $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array.(( ${+region_highlight} )) || { echo >&2 'zsh-syntax-...
# Make it read-only. Can't combine this with the previous line when POSIX_BUILTINS may be set.typeset -r ret # $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array.(( ${+region_highlight} )) || { echo >&2 'zsh-syntax-...
zsh 5.0.5 Last change: January 5, 2014 17 User Commands ZSHMODULES(1) If both param and kparam are supplied, the key is read in `keypad' mode. In this mode special keys such as function keys and arrow keys return the name of the key in the parameter kparam. The key names are ...
fc -R #read from current histfile } mkdir -p $HOME/.zsh_history$PWD export HISTFILE="$HOME/.zsh_history$PWD/zhistory" function allhistory { cat $(find $HOME/.zsh_history -name zhistory) } function convhistory { sort $1 | uniq | ...