1. Check the current system who is logged in: Who
2. Count the logged-in users of the current system: who | Wc-l (L-->line,w-->word,c-->character)
3. Small shell script development cycle: $cat > Nusere new file, using Cat copy terminal input
W.H.O. | Wc-l Input Program Contents
^ D Ctrl+d means End-of-file
$chmod +x nusere Add permissions to this file for execution
$./nusere execute scripts, output results, or/bin/sh nusere
4, #!: Fill in the script execution path, shell script usually the first line abbreviated content is #! /bin/sh
5. Commands and Parameters
(1) Cd/work; LS-L ABC
(2) The command name is the first item in the command line, usually followed by option, any additional parameters are placed in the options
After
(3) The start of the option is a dash, followed by a letter, the option is optional, some may need to add, some can be merged
Ls-l Nusere,ls-lt Nusere
(4) long option use
CD ABC.C
Patch--verbose--BACKUP-P1 </TEMP/ABC.C (I/O redirection, this instruction reads data from a file,
Instead of typing from the keyboard)
(5) Semicolon (;) used to separate multiple commands in the same line;& symbol flag The shell will execute its previous command in the background, which means
The shell can execute the next command without waiting for the command to run.
(6) Three basic commands for Shell recognition: Built-in commands, shell functions, and external commands
Built-in command: The command that the shell itself executes
Shell functions: Shell functions are a series of program code that is functional, written in the shell language, and can be referenced as commands
External command: External command is a command executed by a copy of the shell
A: Create a new process, which is a copy of the shell
B: In the new process, look for specific commands in the directory listed in the PATH variable
C: In the new process, replace the executing shell program with the new program found and execute
D: When the program is complete, the original shell reads the next command from the terminal, or executes the next command in the script
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/80/wKiom1VlbfnicaCmAAD_ptIdjKY174.jpg "title=" program execution. jpg "alt=" wkiom1vlbfnicacmaad_ptidjky174.jpg "/> (7) Variable: is the name of a fragment of a piece of information
A: The format is a caption or an underscore, which can be followed by any length of letters, underscores, numbers
B: Variable name length is not limited, variable assignment length is not limited
C: There is no space in the writing process
D: Single row can be assigned multiple times: FIRSTNAME=SDA lastname=rew Name=fjdskfjdksa
You can use quotation marks when a variable value contains spaces: fullname= "FDSA hgf KJH"
Variable two references no double quotes: oldname= $fullname
(8) Simple echo output
(9) Gorgeous printf output
printf "The first programalwaysprints '%s,%s '" HELLO World
-->the first programalwaysprints ' Hello,world '
(10) Basic I/O redirection: Standard input, standard output, standard error output
I/O redirection is when you interact with the terminal or set it in a shell script. Reschedule from where to enter or output to
Where
(11) Redirection and piping
A: Change the standard input program < file with > to file
B: Change the standard output program > file with > to file
: The redirect does not exist in the target file, if the target file already exists, it will overwrite, the original number of files
According to Lost
C: Append the standard output to the file with >> attached to the program >> files to the end
D: Piping "|", PROGRAM1 | Program2 the standard output of the PROGRAM1 as a standard input for PROGRAM2
More than two programs can be linked together, but also greatly improve the speed of implementation
Eg:tr-d ' \ r ' < Dos-file.txt | Sort > Unix-file.txt First remove the Enter in the file, in the row
Output to a file in the final sequence.
(12) Special documents/DEV/NULL and/dev/tty 46
This article is from the "Tabsang Growth History" blog, please make sure to keep this source http://tabsang.blog.51cto.com/6647507/1655691
Getting Started with Shell scripting