A more detailed introduction to the basics of the Korn shell commonly used on IBM AIX operating systems

Source: Internet
Author: User
Tags aliases line editor

The basics of the Korn shell commonly used on IBM AIX operating systems are described in more detail in the guide.
Korn the order in which the shell executes commands
1. Keywords, such as if,for,function, etc.
2. Aliases (Aliases)
3. Internal commands, such as CDs, whence and functions
4. Function functions
5. Script scripts, executable program in Path
※ Locate the root of the command with the following command:
Whence-v command
Or:
Type command
Alias (aliases)
Alias Aliasname=command
To cancel an alias:
Unalias aliasname
List all current aliases:
Alias
"TIP"
Alias for all directories under explicit current directory: Alias ldir= ' Ls-l|grep ^d '
Question: Alias|grep ^ls will see: Ls=/usr/bin/ls, ask: Why should the system define this alias?
Functions (function)
The location defined:
function can be defined in the command line,. KSHRC (env file, see next article) or in shell script
Define the method:
function FuncName {
Shell commands
}
Or:
FuncName () {
Shell commands
}
List all current functions
Functions
Cancel a function
Unset-f funcname
Output a function:
Typeset-fx funcname
To cancel the output of a function:
typeset +FX funcname
※function is a pre-defined alias for "Typeset-f"
Options for Korn Shell
Korn Shell has some options, if they are set in the. KSHRC (env file, see next article), then they are global and can be passed to Subshell.
List all the Korn shell options:
Set-o
Set an option
Set-o Optionname
Cancel an option
Set +o Optionname
Korn the meaning of Shell options
Allexport Auto Export then defines all the variables (the file name does not contain the.). (Equals Set-a)
Errexit if the return value of a command is not 0, the error trap (ERR trap) is executed. However, the profile file is an exception. (Equals Set-e)
Bgnice the background process runs at a lower priority, which is the default value
Emacs uses Emacs-style inline editor
Gmacs using the Gmacs style inline editor
Ignoreeof does not exit the shell when it encounters a file terminator. To exit the shell you must use the Exit command or Knock ctrl-d 11 times.
keyword in order to maintain compatibility with the Bourne shell. (set-k)
Markdirs after the file name substitution, add a slash (/) after the directory name.
Monitor Runs background jobs in a separate process and prints a line upon completion. (SET-M)
Noclobber cannot overwrite files that already exist with the > redirection character. You can only use >| to rewrite files that already exist. The noexec read-in command only checks its syntax but does not execute. (set-n)
Noglob prohibit file name substitution. (SET-F)
Nolog does not save the definition of the function in the history file.
Nounset displays an error message when attempting to extend a variable that is not defined. (Set-u)
Privileged prohibits execution of home/.profile file and uses/etc/suid _profile instead of env files. (set-p)
Verbose shows the input that the shell reads in. (SET-V)
Trackall designates command as a tracked alias when first encountered. (set-h)
VI in-line editor with VI style
Viraw Processes Each character as it was typed in VI mode.
Xtrace the command is displayed before running the command. (set-x)
※ Example: Make VI an inline editor
Set-o VI
Debuging (Debug)
To debug a shell script method:
#set-O Xtrace
And then run the shell.
or execute directly
#ksh-X Shellprog args
Or
#sh-V Shellprog args
Debug a function
#typeset-ft funcname
Prompts (hint)
PS1 main shell prompt (default is $ for normal user, and root default is #)
PS2 continue prompt (default >)
What is a continuation prompt?
On the command line, enter
For I in 11 12 13 14 15 16
Do
LSPV hdisk$i
Done
Starting with the second line, the left side of the screen is the continuation prompt.
PS3 the selection prompt in the selection loop (the default is #?)
PS4 Debug Prompt (default is +)
"Tip": Prompt for Host name and current directory on the command line
Export ps1= "[' Hostname '-" ' $PWD] '
Note: It must be "" includes "to get the result of the command," including the variable to change the value of the variable at any time
Effect:
[Hostname-/tmp]

A more detailed introduction to the basics of the Korn shell commonly used on IBM AIX operating systems

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.