8.6 Pipe break and job control:
1, cat 1.txt |wc-l; Cat 1.txt |grep ' aaa '
2. Ctrl Z pauses a task
3. Jobs View background tasks
4, Bg[id] The task to the backstage
5. Fg[id] Transfer the task to the front desk
6. Add & Drop the command back to the backstage
The function of the pipe character: Give the result of the previous command output to the following command.
Example:
[[email protected] ~]# ls111 1_heard.txt.bak 1.txt 234 3.txt aming2 anaconda-ks.cfg bb.txt123 1_sorft.txt.bak 1. txt.bak 2.txt 456 aminglinux a.txt [[email protected] ~]# ls |wc - L16[[EMAIL PROTECTED] ~]# FIND ./ -TYPE F./.BASH_LOGOUT./.BASH_PROFILE./.BASHRC. /.cshrc./.tcshrc./.bash_history./.ssh/authorized_keys./anaconda-ks.cfg./2.txt./3.txt./1_heard.txt.bak./1_ Sorft.txt.bak./1.txt.bak./Smart Cloud Platform Introduction (PPT template). pptx./.viminfo./1.txt./a.txt./bb.txt[[email protected] ~]# find ./ -type f |wc -l //The pipeline character calculates how many lines are in front of the command.
8.7/8.8 Shell variables:
1, Path,home,pwd,logname// system variable (can be viewed using echo, such as Echo $PATH)
2. env command//view system environment variable information
3, set command many variables, and include user-defined variable//shell script
4. Custom variable A=1, example:
[[email protected] ~]# A=111[[email protected] ~]# echo $a 111
5, variable name rules: Letters, numbers underline, the first cannot be a number. Example:
[[email protected] ~]# A1=2[[email protected] ~]# echo $a 12[[email protected] ~]# a_1=3[[email protected] ~]# echo $a _13[[ Email protected] ~]# _a1=4[[email protected] ~]# echo $_a14[[email protected] ~]# 1aa=2-bash:1aa=2: Command not found [[email protecte D] ~]# 2aa=3-bash:2aa=3: Command not found
6, the variable value has a special symbol should be enclosed in single quotation marks, example:
[[email protected] ~]# a= ' a b c ' [[email protected] ~]# echo $AA b c[[email protected] ~]# a= "A$BC" [[email protected] ~]# E Cho $aa [[email protected] ~]# a= ' A$BC ' [[email protected] ~]# echo $AA $BC
7, the accumulation of variables, examples:
[[email protected] ~]# a=1[[email protected] ~]# b=2[[email protected] ~]# echo $a $b12[[email protected] ~]# a= ' A$BC ' [[EMA Il protected] ~]# echo $a $ba$bc2[[email protected] ~]# c= "a$b" c//When multiple variables are superimposed, shadow the variable with a double shadow number. [Email protected] ~]# Echo $CA 2c
8. Global variable Export b=2
[[email protected] ~]# Aming=linux//define a variable locally and only take effect on this terminal [[email protected] ~]# echo $aminglinux [[email protected] ~]# Export Aming=linux//Create a global variable [[email protected] ~]# Bash//Open a child shell, the shell is a process. [[email protected] ~]# echo $aminglinux [[email protected] ~]# pstree//A tree-like representation of the derivation of the process, showing a more intuitive effect
9, unset variable, close a variable, the example is as follows:
[Email protected] ~]# echo $aminglinux [[email protected] ~]# unset aming[[email protected] ~]# echo $aming
Extended:
1. See which tty the current user is under, example:
[[email protected] ~]# w19:13:35 up 1 day, 1:14, 2 users, load average:0.00, 0.01, 0.05USER TTY from [Email protected] IDLE jcpu PCPU whatroot pts/0 192.168.4.84 18:27 7.00s 0.21s 0.03s wroot pts/1 192.168.4.84 19:13 6.00s 0.05s 0.05s-bash[[email protected] ~]# echo $SSH _tty/dev/pts/0
8.9 environment variable configuration file:
1, System level etc below, user login load use, generally do not move:
/etc/profile user Environment variables, interaction, login only execution
2, User level, in the user's home directory, the user executes the shell script when the effective, generally do not move:
/ETC/BASHRC//user does not have to log in, execution shell is effective
~/.BASHRC//configuration file when executing shell scripts
~/.bash_profile//Load profile automatically when user logs on
~/.bash_history// record command history files
~/.bash_logout//used to define what needs to be done when a user exits
Note: Each user will have two hidden files, the difference between the two files is to automatically load the profile when the user logs on, and profiles will automatically call BASHRC,BASHRC is the execution of the shell script, the user does not log on, will automatically execute the shell script, As soon as the shell script executes, the configuration file inside the BASHRC is called.
[[email protected] ~]# vim. Bash_profile[[email protected] ~] #source. Bash_profile//source Execute load this file command [email protected] ~]#. . bash_profile//. functions as the source command [[email protected] ~]# vim. BASHRC
3, ps1= ' [\[email protected]\h \w]\$ '//Change the way the user row display environment variables
4, ps1= ' \[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '//change the font color of the user line
650) this.width=650; "title=" 6.png "alt=" 3b454fd8425aec19765ff74514ba7a51.png-wh_ "src=" https://s3.51cto.com/oss/ 201711/16/3b454fd8425aec19765ff74514ba7a51.png-wh_500x0-wm_3-wmp_4-s_4112241372.png "/>
This article is from the "Gary Blog" blog, please be sure to keep this source http://taoxie.blog.51cto.com/10245493/1982602
Shell Fundamentals of Linux Introduction (2)