管道符: |
用法:xxx | yyy 將xxx的輸出結果給yyy處理mysql
[root@axiang-02 ~]# cat 1.txt xxx Math English C++ Experiment Monkey 100 90 95 Good Cat 80 100 60 Perfect Dog 90 60 70 Great Tiger 95 85 90 Fantastic [root@axiang-02 ~]# cat 1.txt |wc -l ; cat 1.txt |grep 95 5 Monkey 100 90 95 Good Tiger 95 85 90 Fantastic
做業控制linux
PATH,HOME,PWD,LOGNAME,SSH_TTYsql
[root@axiang-02 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin [root@axiang-02 ~]# cd /tmp [root@axiang-02 tmp]# echo $HOME /root [root@axiang-02 tmp]# pwd /tmp [root@axiang-02 tmp]# echo $PWD /tmp [root@axiang-02 tmp]# which pwd /usr/bin/pwd [root@axiang-02 tmp]# logname root [root@axiang-02 tmp]# which logname /usr/bin/logname [root@lixiang01 ~]# echo $SSH_TTY 查看本身是那個終端 /dev/pts/3 [root@lixiang01 ~]# w 查看有幾個終端 10:17:53 up 1:06, 3 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.83.1 09:59 16:25 0.21s 0.21s -bash root pts/1 192.168.83.1 10:04 12:59 0.11s 0.11s -bash root pts/3 192.168.83.1 09:55 1.00s 0.71s 0.07s w
查看環境變量shell
[root@axiang-02 tmp]# env | tail LANG=zh_CN.UTF-8 HISTCONTROL=ignoredups SHLVL=1 HOME=/root LOGNAME=root SSH_CONNECTION=10.1.1.1 55509 10.1.1.8 22 LESSOPEN=||/usr/bin/lesspipe.sh %s XDG_RUNTIME_DIR=/run/user/0 _=/usr/bin/env OLDPWD=/root
查看更多變量,包括自定義變量bash
[root@axiang-02 ~]# aaa=axiang [root@axiang-02 ~]# set |grep aaa aaa=axiang
[root@axiang-02 tmp]# a=xxx [root@axiang-02 tmp]# c=a;echo $c 沒$不傳遞值 a [root@axiang-02 tmp]# c=$a;echo $c 有$傳遞值 xxx [root@axiang-02 tmp]# c='$a';echo $c 單引號脫義$ $a [root@axiang-02 tmp]# c="$a";echo $c 雙引號不脫義$ xxx
全局聲明變量,能夠備繼承less
[root@lixiang01 ~]# export a=axianglinux [root@lixiang01 ~]# bash [root@lixiang01 ~]# bash [root@lixiang01 ~]# pstree 用pstree查看,向下生效。是腳本間變量生效 systemd─┬─NetworkManager───2*[{NetworkManager}] ├─agetty ├─anacron ├─auditd───{auditd} ├─chronyd ├─crond ├─dbus-daemon───{dbus-daemon} ├─firewalld───{firewalld} ├─irqbalance ├─master─┬─pickup │ └─qmgr ├─polkitd───5*[{polkitd}] ├─rsyslogd───2*[{rsyslogd}] ├─sshd─┬─sshd─┬─bash───bash───bash───pstree │ │ └─bash │ └─sshd───bash ├─systemd-journal ├─systemd-logind ├─systemd-udevd ├─tuned───4*[{tuned}] └─vmtoolsd───{vmtoolsd} [root@lixiang01 ~]# echo $a axianglinux [root@lixiang01 ~]# unset a 取消定義 [root@lixiang01 ~]# echo $a
用戶家目錄下有本身的環境配置文件,是隱藏的ssh
bashrc和bash_profile的區別 http://ask.apelearn.com/question/7719code