Suggestion: mansh to view the improvements or features on UNIX (1) the shell prompt and its environment can be seen in the passwd file for the shell used by each user after login. the following two files are also
Suggestion:Man sh: View improvements or features on UNIX
(1) shell prompt and its environment
The passwd file shows the shell used by each user after login. the following two files also mean this.
/Etc/passwd file
Prompt: $
/Etc/profile $ HOME/. profile
(2) shell execution options
After a shell script is created, run and test it using the sh command. Below are some common sh parameters.
-N: Test the shell script syntax structure. only shell scripts are read but not executed.
-X: Enter the tracking mode to display each command executed for scheduling.
-A Tag all variables for export
-C "string" reads commands from strings
-E non-interactive mode
-F disable the shell file name generation function
-H locate and remember functions as defind
-I interaction mode
-K read command parameters from environment variables
-R restrictions
-S: Read commands from standard input
-T execute the command and exit (shell exits)
-If undefined variables are used in replacement, the u is incorrect.
-V verbose: displays the shell input line.
These options can be used together, but some of them obviously conflict with each other, such as-e and-I.
(3) restricted shell (Restircted Shell)
It seems that this is useless for a long time.
Sh-r or/bin/rsh
You cannot perform the following operations: cd, change PATH, specify full PATH name, and output redirection. Therefore, you can provide a better control and security mechanism. Generally, rsh is used for application users and dial-up users. these users usually do not see the prompt. The main directory of a restricted user cannot be written.
Disadvantages:If the user can call sh, the rsh restriction will not work. In fact, if the user calls shell in vi and more programs, then the rsh restriction will no longer work.
(4) use set to change shell options
In fact, it is to set the default parameters of sh. when we run shell scripts, we do not always use sh scriptsfile, but use. /scriptsfile to run. the default sh parameter is used at this time. you can use the set command at the $ prompt to set or cancel the shell option, and use the-set option, + cancel the corresponding options. most UNIX systems allow switch setting/cancellation of a, e, f, h, k, n, u, v, and x.
Set-xv
Start tracing method. all commands and replicas are displayed, and input is also displayed.
Set-tu
Disable the check for undefined variables during replacement.
Use echo $-to display all configured shell options.
(5) user startup file. profile
PATH = $ PATH:/usr/loacl/bin; export PATH
(6) shell environment variables
Here is an example of what is an environment variable, but it is still not an environment variable. in my understanding, environment variables are similar to macro definitions, or an environment variable is a global or local variable acting on the system.
CDPATH is used to find the path of the cd command.
HOME/etc/passwd file
IFS Internal Field Separator. the default value is space, tab, and line feed.
Use MAIL/var/mail/$ USERNAME mail and other programs
PATH
PS1, PS2 default prompt ($) and line feed prompt (>)
TERM terminal type. Common types include vt100, ansi, vt200, and xterm.
Example: $ PS1 = "test:"; export PS1
Test: PS1 = "$"; export PS1
$ Echo $ MAIL
/Var/mail/username
(7) reserved characters and their meanings
$ Start of shell variable name, such as $ var
| Pipeline, which transfers the standard output to the standard input of the next command
# Start annotation
& Execute a process in the background
? Match one character
* Matches 0 to multiple characters (different from DOS, which can be used in the middle of the file name and contain .)
$-Use set and the flag passed to shell during execution
$! Process ID of the last sub-process
$ # Number of parameters passed to shell script
$ * Parameters passed to shell script
$ @ All parameters. some parameters are enclosed in double quotation marks.
$? Return code of the previous command
Current shell name
$ N (n: 1-) location parameter
$ Process Identifier Number (PID)
Overwrite existing file data
> File output redirection
This is not clear.
'Command' command replacement, such as filename = 'basename/usr/local/bin/tcsh'
Append data to the end of an existing file.
> Fiile output redirection, append
Escape characters and single quotes:
Note the similarities and differences between single quotes, double quotes, and no quotation marks.
- $ Echo "$ HOME $ PATH"
- /Home/hbwork/opt/kde/bin:/usr/local/bin:/usr/X11R6/bin:
- $ Echo '$ HOME $ path'
- $ HOME $ PATH
- $ Echo $ HOME $ PATH
- $ HOME/opt/kde/bin:/usr/local/bin:/usr/X11R6/bin:/home/hbwork/bin
Others:
- $ Dir = ls
- $ Dir
- $ Alias dir ls
- $ Dir
Output ls results to filelist
Ls> filelist
Append the ls result to the end of the filelist file.
Ls> filelist
Count the number of rows in the filelist file
Wc-l <filelist
Count the total number of rows of the string filelist
Wc-l filelist
Wait for 5 seconds, display 5 seconds reaches, and execute the ls-l command
Sleep 5; echo 5 seconds reaches; ls-l
[Find all inetd processes in the current process]
Ps ax | grep inetd
I don't understand this. find won't be used.
Find/-name core-exec rm {};&
Set filename to date + year, month, and day. log
Filename = 'date "+ % Y % m % d" '. log