shell脚本笔记
    
2019-02-16
  
    
    
  
2019-02-16
传参
| zsh ./fuck.sh $1 $2 $3 ... | 
赋值
- 不要加空格
if
示例:
| if [ "${message}"x = x ] | 
- 注意[``]的空格和关系运算符的空格
- 注意字符串比较时为空的情况
- 更多
for
处理特定前缀的文件
| for img in `ls` | 
while
一个修改缩进的脚本
| line_num=$(wc -l $1) | 
字符串处理
sed
mac(FreeBSD)
示例
| sed -i '' -e '4a\ | 
或
| sed -i '' -e '4a\ | 
linux
| sed -i '4a\shit' ${filename} | 
或
| sed -i '4a\'${message} ${filename} | 
计算字符长度
| ${#string} | 
sleep
read
数组
| sh=() |