Shell Grammer
语言分类:编译语言,解释语言,汇编语言 编译语言: C / C++ / JAVA 强类型: 使用前必须声明变量类型 过程:源程序-->编译 -->链接 -->执行 基本变量类型:字符、整数、浮点数 解释语言: BASH / PERL / PYTHON / PHP / ruby 弱类型:直接使用变量 过程:源程序-->执行 默认变量类型:字符 "":弱引用 变量替换 ‘’:强引用 不做变量替换 `:命令替换 声明变量:declare 语法:declare <类型> <变量名> 类型:-i 整数 、-r 只读变量、-x 环境变量、 -a 数组 释放变量: unset 语法:unset <变量名> 只读变量(常量):readonly 语法:readonly <变量名> 默认环境变量都是大写,自定义变量尽量小写或者首字母大写 config file sequence Login shell: 1. /etc/profile 2. ~/.bash_profile 3. ~/.bashrc 4. /etc/bashrc Last run file is ~/.bash_profile Normal shell: 1. ~/.bashrc 2. /etc/bashrc PS1 提示符 \W: relative path \w: absolute path \h: hostname \u: username \t: 24 hour \T: 12 hour Default PS1="[\u@\h \W] \\$" Exampe: PS1="\u \h \w \t \\$" 系统变量: /etc/profile, ~/.bash_profile: 会话时读取一次 /etc/bashrc, ~/bashrc: 每次打开终端读取 /etc/profile.d:为不同版本shell特殊用法说明 用户变量 .bash_profile: 会话时读取一次 .ba...