8.6 Pipe symbol and job control
cat 1.txt |wc -l;cat 1.txt |grep ‘aaa‘ctrl+z 暂停一个任务jobs 查看后台的任务bg[id] 把任务调到后台fg[id] 把任务调到前台命令后面加 & 直接丢到后台
8.7 The shell variable
The path,home,pwd,lognameenv command set command has many more variables, and includes user-defined variable custom variables a=1 variable naming conventions: Letters, numbers, underscores, the first cannot be a special symbol for a numeric variable value, The cumulative global variable of the variable that needs to be enclosed in single quotation marks export b=2unset variable [[email protected] ~]# env xdg_session_id=1 hostname=aming-01 SELINUX _role_requested= term=xterm-256color shell=/bin/bash histsize=2000 ssh_client=192.168.104.1 55630 x_use_current_range= oldpwd=/tmp/d6z ssh_tty=/dev/pts/0 user=root ls_colors=rs=0:di=38;5;27:ln=38;5;51:mh=44;3 8;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5 ; 232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21 : st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:* . lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38 ; 5;9:*. Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5; 9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*. ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38; 5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38 ; 5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*. svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5; 13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38 ; 5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv= 38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv= 38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*. Midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*. Spx=38;5;45:*.xspf=38;5;45:mail=/var/spool/mail/root path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/ Root/bin pwd=/root LANG=ZH_CN. UTF-8 selinux_level_requested= histcontrol=ignoredups shlvl=1 home=/root logname=root SSH_CONNECTION=192 .168.104.1 55630 192.168.104.160-lessopen=| | /usr/bin/lesspipe.sh%s xdg_runtime_dir=/run/user/0 _=/usr/bin/env [[email protected] ~]# a1=2 [[EMAIL&NB Sp;protected] ~]# echo $a 1 2 [[email protected] ~]# a_2=3 [[email protected] ~]# Echo $a _2 3 [[E Mail protected] ~]# _a3=4 [[email protected] ~]# echo $_a3 4 [[email protected] ~]# 5a=6-bash : 5a=6: Command not found [[email protected] ~]# a= ' A$BC ' [[email protected] ~]# echo $a A$BC [[Email prote CTED] ~]# b= "A$BC" [[email protected] ~]# echo $b a [[Email pRotected] ~]# b=2 [[email protected] ~]# c=a "$b" C [[email protected] ~]# echo $c a2c
8.8 The shell variable
[[email protected] ~]# w 23:57:06 up 1:53, 1 user, load average:0.00, 0.01, 0.05 user TTY FRO M [email protected] IDLE jcpu PCPU what root pts/0 192.168.104.1 22:04 2.00s 0.23s 0.00s w [[email protected] ~]# echo $SSH _tty/dev/pts/0 non-global variable, valid export b=1 global variable only at current login TTY, only valid shell in current shell Variables are local, and environment variables are global. Environment variables are set by shell commands, and set environment variables can be used by all current users running programs. For bash, the shell program can use variable names to access the appropriate environment variables, and export to set environment variables. Vi. Bash_profile #修改用户环境变量文件需要注意的是, it is best not to put the current path "./" into path, which may be subject to unexpected attacks. Three ways to set variables 1. Add a variable in the/etc/profile file "for all users (permanent)" Use VI to add a variable to the file/etc/profile file, which will be valid for all users under Linux and is "permanent". For example: Edit the/etc/profile file, add CLASSPATH variable # vi/etc/profile export classpath=./java_home/lib; $JAVA _home/jre/lib Note: If you want to make a change to the file, you need to run the # Source/etc/profile. 2. Add the variable "to single user (permanent)" in the. bash_profile file in the user directory with VI in the user directory. Adding variables to the Bash_profile file, the amount of change is only valid for the current user and is "permanent". Example: Edit the Guok user directory (/homE/guok). Bash_profile $ vi/home/guok/.bash.profile Add the following: Export classpath=./java_home/lib; $JAVA _h Ome/jre/lib Note: If you want to take effect immediately after you modify the file, you will have to run $ source/home/guok/.bash_profile. 3. Run the export command to define the variable "only for the current shell (bash) Valid (temporary) define a variable directly under the shell's command line using [export variable name = variable value], which is valid only under the current shell (bash) or its child shell (bash), the shell is closed, and the variable is invalidated. There is no such variable when you open the new shell, and you need to redefine it.
8.9 environment variable configuration file
/etc/profile #用户环境变量,交互,登陆才执行/etc/bashrc #用户不用登陆,执行 shell 就生效~/.bashrc~/.bash_profile~/.bash_history~/.bash_logout #用户退出时,需要做的动作,如删除命令历史记录/etc/profile /etc/bashrc 不要轻易修改这两个环境变量配置文件,建议修改用户环境变量 ~/.bashrc ~/.bash_profile
2018-03-08 Amin Linux Learning