Friday, December 10, 2010

Dialogue on UNIX: learning more command-line skills and operators

Better understand UNIX? user input these "strange" characters.

Learn how to use pipes in UNIX, redirect, operators, and other characteristics. Now that you have at IBM working on AIX?? for some time. You have to learn a few basic commands to move the directory structure, create and modify files, view the running processes, and manage user and system. This is very good, but you want to learn UNIX administrator input of the command line. The command contains a lot of strange symbols. In this article, see |, >, >, > <><、[[和]]等符号在unix和linux?中的意思,以及如何使用&&、||> 、 <><=和!=操作符。> If you are familiar with the UNIX pipe, the pipe (or pipe) is exposed to every day. The pipeline was originally developed by MalcolmMcIlroy, you can use the pipe to a command's standard output (stdout) directed to the next command's standard input (stdin), thus forming a continuous chain of command. In a command line using multiple pipelines. In many cases, a command's stdout is used as the next command of stdin, and the second command's stdout and be redirected to another command's stdin, and so on. For example, when troubleshooting or perform routine checks, most UNIX administrator first thing is to view the systems currently running processes. Listing 1 demonstrates such a check. Listing 1. daily process check sample # ps-eUIDPIDPPIDCSTIMETTYTIMECMDroot100Jul27-0: 05/etc/initroot534421516740Jul27-0: 00/usr/sbin/syslogdroot5742610Jul27-0: 00/usr/lib/errdemonroot6151010Jul27-23: 55/usr/sbin/syncd60root6563410Jul27-0: 00/usr/ccs/bin/shlap64root820021106520Jul27-0: 24/usr/lpp/X-xabx-xdbe-xGLX-D X11/bin/usr/lib//X11//rgb-T-force: 0-auth/var/dt/A: 0-SfIdMaroot8610210Jul27-0: 00/usr/lib/methods/ssa_daemon-lssa0root1065381516740Jul27-0: 01sendmail: acceptingconnectionsroot11065210Jul27-0: 00/usr/dt/bin/dtlogin-daemonroot1147541188540Jul27-20: 0: 00dtlogin 22dtgreetroot1188541106520Jul27-<:0>-daemonroot13108810Jul27-07/0: atria/usr/etc/lockmgr-a/var/adm/atria/almd-q1024-u256-f256root14758410Jul27-0: 01/usr/sbin/cronroot1558161516740Jul27-0: 04/usr/sbin/portmaproot1639681516740Jul27-0: 00/usr/sbin/qdaemonroot1680181516740Jul27-0: 00/usr/sbin/inetdroot1721161516740Jul27-0: 03/usr/sbin/xntpdroot1803141516740Jul27-0: 19/usr/sbin/snmpmibdroot1844141516740Jul27-0: 21/usr/sbin/aixmibdroot1885121516740Jul27-0: 20/usr/sbin/hostmibdroot1926081516740Jul27-7: 46/usr/sbin/muxatmdroot196718151674011: 00: 27-0: 00/usr/sbin/rpc.mountdroot2008181516740Jul27-0: 00/usr/sbin/biod6root2131081516740Jul27-0: 00/usr/sbin/nfsd3891root2213042458940Jul27-0: 05/bin/nsrexecddaemon225402151674011: 00: 27-0: 00/usr/sbin/rpc.statdroot229498151674011: 00: 27-0: 00/usr/sbin/rpc.lockdroot2417941516740Jul27-0: 51/usr/lib/yp/netsvc/ypbindroot24589410Jul27-0: 00/bin/nsrexecdroot25396010Jul27-0: 00./mflm_managerroot2745681516740Jul27-0: 00/usr/sbin/ssd-Droot28276610Jul27lft00: 00/usr/sbin/getty/dev/consoleroot29095810Jul27-0: 00/usr/lpp/diagnostics/bin/diagdroot3156461516740Jul27-0: 00/usr/sbin/lpdroot31966410Jul27-0: 00/usr/atria/etc/albd_serverroot340144168018012: 34: 56-0: 0: 00rpc.ttdbserver1000831root3768461680180Jul30-00rlogindcormany409708569522019: 29: 27pts/10: 00-ks root569522168018019: 29: 26-0: 30: 00rlogindcormany733188409708319: 34pts/10: 00ps-e root7496681680180Jul30-0: 00rlogind systems currently running process list might look like listing 1 so simple; however, most production systems running process more, this makes the output of ps. In order to keep this list to your own needs, you can use the pipeline to ps-ef's standard output redirected to grep to search for your really want to see the results. Listing 2 to listing 1 creates process list redirects to grep, search string "rpc" and "ksh". 2. the list of the processes list redirects to grep # ps-ef | grep-E "rpc | ks root196718151674011: 00: 27-0: 00/usr/sbin/rpc.mountddaemon225402151674011: 00: 27-0: 00/usr/sbin/rpc.statdroot229498151674011: 00: 27-0: 00/usr/sbin/rpc.lockdroot340144168018012: 34: 56-0: 29: 00rpc.ttdbserver1000831cormany409708569522019: 27pts/10: 00-ks cormany733202409708019: 52 20pts/10: 00grep-Erpc | ks when repeatedly to redirect stdout, stdin piping using methods can be very complex. The following example extends the previous ps and grep examples, to its stdout redirect to another grep, whose role is to exclude contains "grep" or "ttdbserver" string. When the last grep operation to complete, again using the pipeline to stdout redirected to an awk statement, whose role is to output the process identifier (PID) is greater than all the processes: 200,000 # ps-ef | grep-E "rpc | ksh" | grep "grep-vE | rpc.ttdbserver | awk-v_MAX_PID = 200000 ' {if ($ 2 > _MAX_PID) {print" $ PIDorprocess "," 8 ", isgreaterthan _MAX_PID}} ' PIDforprocess/usr/sbin/usr/sbin/rpc.statdisgreaterthan200000PIDforprocess/rpc.lockdisgreaterthan200000PIDforprocess-kshisgreaterthan200000 figure 1 through a graphical description of the command's stdout redirect stdin to subsequent commands in the order. The example in Figure 1. piping

No comments:

Post a Comment