Aix shell Basics

Source: Internet
Author: User

Shell is an interface between the operating system and the user. It can explain the commands issued by the user, start the application, and use the system functions to manage user data. Shell can run multiple processes at the front end or backend under the user's interactive control. Shell is also an effective programming language.


1. wildcard characters

1) *: Multiple Arbitrary characters

$ Ls

Info newdir test. file testfile

Mbox newtest. file test1.file wangyi

$ Ls *.*

Newtest. file test. file test1.file


2 )? : Any character

$ Ls ????. *

Test. file


3) []: A single character []

$ Ls [mt] *

Mbox test. file test1.file


4) [-]: A single character in the range [-]

$ Ls [m-w] *

Mbox newtest. file test. file test1.file testfile

Newdir:

Wangyi:


5 )! : Not a certain character

$ Ls [! T] *

Mbox newtest. file

Info:

Notes tmp

Newdir:

Wangyi:

Test. file


2. Standard Input and Output

In the standard AIX status, the input is from the keyboard, the output is to the screen, and the error information is displayed on the screen.

Redirection symbol system variable name

Standard Input <) 0

Standard output> (>) 1

Standard Error output 2> (2>) 2


3/Redirection

Standard input, output, and error messages in the AIX environment can be reoriented, so that users can obtain the input information from other places, such as files and serial ports, outside the keyboard, and the input content and error information to other places outside the screen, such as files ).

● Input redirection

$ Command <filename

$ Mail xumin <test. file

● Output redirection

$ Command> filename

$ Ls> out. file

$ Cat out. file

28

Info

Mbox

Newdir

Newtest. file

Out. file

Test. file

Test1.file

Testfile

Wangyi

● Error message redirection

$ Command 2> filename

$ Ls test2.file 2> error. out

$ Cat error. out

Ls: 0653-341 The file test2.file does not exist.

● Combined redirection

$ Command <infile> outfile 2> errfile

$ Command> outfile 2> errfile <infile

$ Ls test1.file test2.file> out. file 2> error. file

$ Cat out. file

Test1.file

$ Cat error. file

Ls: 0653-341 The file test2.file does not exist.

● Link combination redirection

$ Command> outfile 2> & 1

& 1 points to out. file, because the standard output of the original system has been redirected to out. file.

$ Command 2> & 1> outfile

Here & 1 points to the standard output. At this time, the standard output of the original system has not changed.


4. Pipelines

MPs queue uses the output of the previous command as the input of the next command.

MPs queue usage:

$ Command1 | command2

$ Ls | wc-w


5. Split output

The tee command can read the standard input and send the data to the standard output and specified files at the same time.

Tee usage:

$ Command1 | tee filename | command2

$ Ls | tee out. file | wc

11 11 97

$ Cat out. file

Error. file

Error. out

Info

Mbox

Newdir

Newtest. file

Out. file

Test. file

Test1.file

Testfile


6. Multiple commands

In AIX, shell allows multiple commands to be written in the same line. You only need to add ";" between commands as the separator.

Usage:

$ Command1; command2; command3

$ Pwd; cd/; ls

/Home/xumin

Slider. class dead. letterlost + found smit. script usr

TT_DB dev lpp testnfs var

Aaaa etc mnt testxmg websm. log

Adsmtest home opt testxmgxumin

Bin info sbin tftpboot xumin_disk1

Cdrom info. www share tmp

Cds. types informix showcase u

Core lib smit. log unix


7. Long Commands

When you write a long command in the AIX shell, you can use "\" as the line break tag. In this case, shell uses a ">" as the prompt.


8. variables in the Shell Environment

Variables can be defined in the shell environment for systems, users, shell programs and various applications. Variables can be defined by the system or by the user. You can also modify or delete the variables that have been defined by the system.

Example: HOME -- user's home directory

TERM -- terminal type

PATH -- command search PATH


9. View and define variables

1) view the Defined variables

$ Set

~~~

~~~

HOME =/home/xumin

LANG = En_US

LOCPATH =/usr/lib/nls/loc

LOGIN = xumin

LOGNAME = xumin

MAIL =/usr/spool/mail/xumin

Mailcheck= 600

MAILMSG = '[you have new mail]'

~~~

~~~

PATH =/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/xumin/bin:/usr/bin/X11:/sbin :.

PPID = 69504 nput

PS1 = '$'

PS2 = '>'

PS3 = '#'

PS4 = '+'

PWD =/

RANDOM = 31884.

32

SECONDS = 2774

SHELL =/usr/bin/ksh

TERM = ANSI

TERM_DEFAULT = lft

TMOUT = 0

TZ = CST6CDT

USER = xumin


2) DISPLAY variable values

$ Echo $ name

$ Echo $ HOME

/Home/xumin


3) define variables

$ Name = value

$ Echo $ xxx

$ Xxx = hello!

$ Echo $ xxx

Hello!


4) delete a variable

$ Unset

$ Unset xxx

$ Echo $ xxx


5) Use of Variables

'': Use the content between'' as a command to return the command result.

$ Now = 'date'

$ Echo $ now

Wed Aug 12 15:23:19 CDT 1998

'': NO content''

$ Echo '$ home'

$ HOME

"": It will explain the special meanings of the $, '', and \ characters "".

$ Echo "now is 'date '"

Now is Wed Aug 12 15:32:41 CDT 1998

\: Special meaning of special characters after ignoring \

$ Echo \ $ HOME

$ HOME


Oracle video tutorial follow: http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html


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.