1. Trang chủ
  2. » Ngoại Ngữ

solaris 9 user command phần 3 pot

183 361 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

The following example violates Rule 5: options with option-arguments must not be grouped with other options: example% cmd -aboxxx filename The following example violates Rule 6: there must be white space after an option that takes an option-argument: example% cmd -ab oxxx filename Changing the value of the shell variable OPTIND or parsing different sets of arguments may lead to unexpected results. Checks arg for legal options. If arg is omitted, the positional parameters are used. An option argument begins with a + or a −. An option not beginning with + or − or the argument – ends the options. optstring contains the letters that getopts recognizes. If a letter is followed by a :, that option is expected to have an argument. The options can be separated from the argument by blanks. getopts places the next option letter it finds inside variable name each time it is invoked with a + prepended when arg begins with a +. The index of the next arg is stored in OPTIND. The option argument, if any, gets stored in OPTARG. A leading : in optstring causes getopts to store the letter of an invalid option in OPTARG, and to set name to ? for an unknown option and to : when a required option is missing. Otherwise, getopts prints an error message. The exit status is non-zero when there are no more options. For a further discussion of the Korn shell’s getopts built-in command, see the previous discussion in the Bourne shell (sh) section of this manpage. The following operands are supported: optstring A string containing the option characters recognised by the utility invoking getopts. If a character is followed by a colon, the option will be expected to have an argument, which should be supplied as a separate argument. Applications should specify an option character and its option-argument as separate arguments, but getopts will interpret the characters following an option character requiring arguments as an argument whether or not this is done. An explicit null option-argument need not be recognised if it is not supplied as a separate argument when getopts is invoked; see getopt(3C). The characters question-mark (?) and colon (:) must not be used as option characters by an application. The use of other option characters that are not alphanumeric produces unspecified results. If the option-argument is not supplied as a separate argument from the option character, the value in OPTARG will be stripped of the option character and the −. getopts(1) ksh OPERANDS User Commands 499 The first character in optstring will determine how getopts will behave if an option character is not known or an option-argument is missing. name The name of a shell variable that will be set by the getopts utility to the option character that was found. The getopts utility by default will parse positional parameters passed to the invoking shell procedure. If args are given, they will be parsed instead of the positional parameters. Since getopts affects the current shell execution environment, it is generally provided as a shell regular built-in. If it is called in a subshell or separate utility execution environment, such as one of the following: (getopts abc value "$@") nohup getopts find . -exec getopts \; it will not affect the shell variables in the caller’s environment. Notice that shell functions share OPTIND with the calling shell even though the positional parameters are changed. Functions that want to use getopts to parse their arguments will usually want to save the value of OPTIND on entry and restore it before returning. However, there will be cases when a function will want to change OPTIND for the calling shell. EXAMPLE 1 Parsing and displaying arguments The following example script parses and displays its arguments: aflag= bflag= while getopts ab: name do case $name in a) aflag=1;; b) bflag=1 bval="$OPTARG";; ?) printf "Usage: %s: [-a] [-b value] args\n" $0 exit 2;; esac done if[!-z"$aflag" ]; then printf "Option -a specified\n" fi if[!-z"$bflag" ]; then printf ’Option -b "%s" specified\n’ "$bval" fi shift $(($OPTIND - 1)) printf "Remaining arguments are: %s\n" "$*" getopts(1) USAGE EXAMPLES 500 man pages section 1: User Commands • Last Revised 7 Jan 2000 EXAMPLE 1 Parsing and displaying arguments (Continued) EXAMPLE 2 Processing arguments for a command with options The following fragment of a shell program shows how one might process the arguments for a command that can take the options -a or -b, as well as the option -o, which requires an option-argument: while getopts abo: c do case $c in a | b) FLAG=$c;; o) OARG=$OPTARG;; \?) echo $USAGE exit 2;; esac done shift ‘expr $OPTIND − 1‘ EXAMPLE 3 Equivalent code expressions This code accepts any of the following as equivalent: cmd -a -b -o "xxx z yy" filename cmd -a -b -o "xxx z yy" filename cmd -ab -o xxx,z,yy filename cmd -ab -o "xxx z yy" filename cmd -o xxx,z,yy -b -a filename See environ(5) for descriptions of the following environment variables that affect the execution of getopts: LC_CTYPE, LC_MESSAGES, and NLSPATH. OPTIND This variable is used by getopts as the index of the next argument to be processed. OPTARG This variable is used by getopts to store the argument if an option is using arguments. The following exit values are returned: 0 An option, specified or unspecified by optstring, was found. >0 The end of options was encountered or an error occurred. See attributes(5) for descriptions of the following attributes: ATTRIBUTE TYPE ATTRIBUTE VALUE Availability SUNWcsu intro(1), getoptcvt(1), ksh(1), sh(1), getopt(3C), attributes(5), environ(5) getopts(1) ENVIRONMENT VARIABLES EXIT STATUS ATTRIBUTES SEE ALSO User Commands 501 Whenever an error is detected and the first character in the optstring operand is not a colon (:), a diagnostic message will be written to standard error with the following information in an unspecified format: ■ The invoking program name will be identified in the message. The invoking program name will be the value of the shell special parameter 0 at the time the getopts utility is invoked. A name equivalent to basename "$0"may be used. ■ If an option is found that was not specified in optstring, this error will be identified and the invalid option character will be identified in the message. ■ If an option requiring an option-argument is found, but an option-argument is not found, this error will be identified and the invalid option character will be identified in the message. getopts(1) DIAGNOSTICS 502 man pages section 1: User Commands • Last Revised 7 Jan 2000 gettext – retrieve text string from message database gettext [-d textdomain |-−domain=textdomain][textdomain] msgid gettext -s [-e] [-n] [-d textdomain |-−domain=textdomain]msgid… The gettext utility retrieves a translated text string corresponding to string msgid from a message object generated with msgfmt(1). The message object name is derived from the optional argument textdomain if present, otherwise from the TEXTDOMAIN environment. If no domain is specified, or if a corresponding string cannot be found, gettext prints msgid. Ordinarily, gettext looks for its message object in /usr/lib/locale/lang/LC_MESSAGES where lang is the locale name. If present, the TEXTDOMAINDIR environment variable replaces the pathname component up to lang. This command interprets C escape sequences such as \t for tab. Use \\ to print a backslash. To produce a message on a line of its own, either enter \n at the end of msgid, or use this command in conjunction with printf(1). When used with the -s option, gettext behaves like echo(1). But it does not simply copy its arguments to standard output. Instead, those messages found in the selected catalog are translated. The following options are supported: -d textdomain -−domain=textdomain Retrieves translated messages from the domain textdomain,iftextdomain is not specified as an operand. -e Enables expansion of some escape sequences if used with the -s option. -n Suppresses trailing newline if used with the -s option. -s Behaves like echo(1) (see DESCRIPTION above). If the -s option is specified, no expansion of C escape sequences is performed and a newline character is appended to the output, by default. The following operands are supported: textdomain A domain name used to retrieve the messages. This overrides the specification by the -d or -−domain options, if present. msgid A key to retrieve the localized message. LANG Specifies locale name. LC_MESSAGES Specifies messaging locale, and if present overrides LANG for messages. gettext(1) NAME SYNOPSIS DESCRIPTION OPTIONS OPERANDS ENVIRONMENT VARIABLES User Commands 503 TEXTDOMAIN Specifies the text domain name, which is identical to the message object filename without .mo suffix. TEXTDOMAINDIR Specifies the pathname to the message database. If present, replaces /usr/lib/locale. See attributes(5) for descriptions of the following attributes: ATTRIBUTE TYPE ATTRIBUTE VALUE Availability SUNWcsu echo(1), msgfmt(1), printf(1), gettext(3C), setlocale(3C), attributes(5) This is the shell equivalent of the library routine gettext(3C). gettext(1) ATTRIBUTES SEE ALSO NOTES 504 man pages section 1: User Commands • Last Revised 17 Sep 2001 gettxt – retrieve a text string from a message database gettxt msgfile : msgnum [dflt_msg] gettxt retrieves a text string from a message file in the directory /usr/lib/locale/locale/LC_MESSAGES . The directory name locale corresponds to the language in which the text strings are written; see setlocale(3C). msgfile Name of the file in the directory /usr/lib/locale/locale/LC_MESSAGES to retrieve msgnum from. The name of msgfile can be up to 14 characters in length, but may not contain either \0 (null) or the ASCII code for / (slash) or : (colon). msgnum Sequence number of the string to retrieve from msgfile. The strings in msgfile are numbered sequentially from 1 to n, where n is the number of strings in the file. dflt_msg Default string to be displayed if gettxt fails to retrieve msgnum from msgfile. Nongraphic characters must be represented as alphabetic escape sequences. The text string to be retrieved is in the file msgfile, created by the mkmsgs(1) utility and installed under the directory /usr/lib/locale/locale/LC_MESSAGES . You control which directory is searched by setting the environment variable LC_MESSAGES.If LC_MESSAGES is not set, the environment variable LANG will be used. If LANG is not set, the files containing the strings are under the directory /usr/lib/locale/C/LC_MESSAGES . If gettxt fails to retrieve a message in the requested language, it will try to retrieve the same message from /usr/lib/locale/C/LC_MESSAGES/ msgfile. If this also fails, and if dflt_msg is present and non-null, then it will display the value of dflt_msg; if dflt_msg is not present or is null, then it will display the string Message not found!!. EXAMPLE 1 The environment variables LANG and LC_MESSAGES. If the environment variables LANG or LC_MESSAGES have not been set to other than their default values, the following example: example% gettxt UX:10 "hello world\n" will try to retrieve the 10th message from /usr/lib/locale/C/UX/msgfile.Ifthe retrieval fails, the message "hello world," followed by a newline, will be displayed. See environ(5) for descriptions of the following environment variables that affect the execution of gettxt: LC_CTYPE and LC_MESSAGES. LC_CTYPE Determines how gettxt handles characters. When LC_CTYPE is set to a valid value, gettxt can display and handle text and filenames containing valid gettxt(1) NAME SYNOPSIS DESCRIPTION EXAMPLES ENVIRONMENT VARIABLES User Commands 505 characters for that locale. gettxt can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide. gettxt can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid. LC_MESSAGES Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses. In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English). /usr/lib/locale/C/LC_MESSAGES/* default message files created by mkmsgs(1) /usr/lib/locale/locale/LC_MESSAGES/* message files for different languages created by mkmsgs(1) See attributes(5) for descriptions of the following attributes: ATTRIBUTE TYPE ATTRIBUTE VALUE Availability SUNWloc CSI Enabled exstr(1), mkmsgs(1), srchtxt(1), gettxt(3C), setlocale(3C), attributes(5), environ(5) gettxt(1) FILES ATTRIBUTES SEE ALSO 506 man pages section 1: User Commands • Last Revised 20 Dec 1996 glob – shell built-in function to expand a word list glob wordlist glob performs filename expansion on wordlist. Like echo(1), but no ‘\’ escapes are recognized. Words are delimited by null characters in the output. See attributes(5) for descriptions of the following attributes: ATTRIBUTE TYPE ATTRIBUTE VALUE Availability SUNWcsu csh(1), echo(1), attributes(5) glob(1) NAME csh csh ATTRIBUTES SEE ALSO User Commands 507 gprof – display call-graph profile data gprof [-abcCDlsz] [-e function-name] [-E function-name] [-f function-name] [-F function-name][image-file [profile-file…]] [-n number of functions] The gprof utility produces an execution profile of a program. The effect of called routines is incorporated in the profile of each caller. The profile data is taken from the call graph profile file that is created by programs compiled with the -xpg option of cc(1), or by the -pg option with other compilers, or by setting the LD_PROFILE environment variable for shared objects. See ld.so.1(1). These compiler options also link in versions of the library routines which are compiled for profiling. The symbol table in the executable image file image-file (a.out by default) is read and correlated with the call graph profile file profile-file (gmon.out by default). First, execution times for each routine are propagated along the edges of the call graph. Cycles are discovered, and calls into a cycle are made to share the time of the cycle. The first listing shows the functions sorted according to the time they represent, including the time of their call graph descendants. Below each function entry is shown its (direct) call-graph children and how their times are propagated to this function. A similar display above the function shows how this function’s time and the time of its descendants are propagated to its (direct) call-graph parents. Cycles are also shown, with an entry for the cycle as a whole and a listing of the members of the cycle and their contributions to the time and call counts of the cycle. Next, a flat profile is given, similar to that provided by prof(1). This listing gives the total execution times and call counts for each of the functions in the program, sorted by decreasing time. Finally, an index is given, which shows the correspondence between function names and call-graph profile index numbers. A single function may be split into subfunctions for profiling by means of the MARK macro. See prof(5). Beware of quantization errors. The granularity of the sampling is shown, but remains statistical at best. It is assumed that the time for each execution of a function can be expressed by the total time for the function divided by the number of times the function is called. Thus the time propagated along the call-graph arcs to parents of that function is directly proportional to the number of times that arc is traversed. The profiled program must call exit(2) or return normally for the profiling information to be saved in the gmon.out file. The following options are supported: -a Suppress printing statically declared functions. If this option is given, all relevant information about the static function (for instance, time samples, calls to other functions, calls from other functions) belongs to the function loaded just before the static function in the a.out file. gprof(1) NAME SYNOPSIS DESCRIPTION OPTIONS 508 man pages section 1: User Commands • Last Revised 27 Jul 1998 [...]... "\t%s\n", EXAMPLES EXAMPLE 1 Using history and fc csh ksh % history 1 cd /etc 2 vi passwd 3 date 4 cd 5 du 6 ls -t 7 history $ fc -l 1 cd /etc 2 vi passwd 3 date 4 cd 5 du 6 ls -t 7 fc -l % !d du 262 33 6 $ fc -e - d du 262 /SCCS 33 6 /SCCS % !da Thu Jul 21 17: 29: 56 PDT 199 4 $ fc -e - da Thu Jul 21 17: 29: 56 PDT 199 4 % $ alias \!=’fc -e -’ User Commands 533 history(1) EXAMPLE... section 1: User Commands • Last Revised 30 Oct 199 5 fc 30 40 fc -r 40 30 history(1) I When a range of commands is used, it will not be an error to specify first or last values that are not in the history list; fc will substitute the value representing the oldest or newest command in the list, as appropriate For example, if there are only ten commands in the history list, numbered 1 to 10: fc -l fc 1 99 will... entire line man pages section 1: User Commands • Last Revised 20 Oct 199 7 grep(1) /usr/xpg4/bin/grep The results are unspecified if input files contain lines longer than LINE_MAX bytes or contain binary data LINE_MAX is defined in /usr/include/limits.h User Commands 5 19 groups(1) NAME SYNOPSIS DESCRIPTION EXAMPLES groups – print group membership of user groups [user ] The command groups prints on standard... -r, with each command preceded by the command number -n Suppress command numbers when listing with -l User Commands 531 history(1) -r -s OPERANDS Reverse the order of the commands listed (with -l ) or edited (with neither -l nor -s) Re-execute the command without invoking an editor The following operands are supported: first last Select the commands to list or edit The number of previous commands that... respectively, all ten commands old=new OUTPUT Replace the first occurrence of string old in the commands to be reexecuted by the string new When the -l option is used to list commands, the format of each command in the list is as follows: "%d\t%s\n", , If both the -l and -n options are specified, the format of each command is: "\t%s\n", If the commandcommand consists of... containing these keyboard commands If ename is not supplied, then the value of the 530 man pages section 1: User Commands • Last Revised 30 Oct 199 5 history(1) variable FCEDIT (default /bin/ed) is used as the editor When editing is complete, the edited command( s) is executed If last is not specified then it will be set to first If first is not specified the default is the previous command for editing and... group(4), passwd(4), attributes(5) man pages section 1: User Commands • Last Revised 14 Sep 199 2 ATTRIBUTE VALUE SUNWcsu groups(1B) NAME SYNOPSIS DESCRIPTION FILES groups – display a user s group memberships /usr/ucb/groups [user ] With no arguments, groups displays the groups to which you belong; else it displays the groups to which the user belongs Each user belongs to a group specified in the password file... place or the command gets executed Event Designators: An event designator is a reference to a command line entry in the history list ! !! Refer to the previous command By itself, this substitution repeats the previous command !n Refer to command line n !-n Refer to the current command line minus n !str Refer to the most recent command starting with str !?str? Refer to the most recent command containing... multiple commands will be accomplished by presenting to the editor all of the commands at one time, each command starting on a new line If first represents a newer command than last, the commands will be listed or edited in reverse sequence, equivalent to using -r For example, the following commands on the first line are equivalent to the corresponding commands on the second: I I fc -r 10 20 fc 20 10 532 ... attributes(5) for descriptions of the following attributes: User Commands 525 head(1) ATTRIBUTE TYPE ATTRIBUTE VALUE Availability CSI SEE ALSO 526 SUNWcsu enabled cat(1), more(1), pg(1), tail(1), attributes(5), environ(5), largefile(5) man pages section 1: User Commands • Last Revised 1 Feb 199 5 history(1) NAME SYNOPSIS history, fc – process command history list /usr/bin/fc [first [last]] /usr/bin/fc . SUNWbtool gprof(1) ENVIRONMENT VARIABLES FILES ATTRIBUTES 510 man pages section 1: User Commands • Last Revised 27 Jul 199 8 cc(1), ld.so.1(1), prof(1), exit(2), pcsample(2), profil(2), malloc(3C), malloc(3MALLOC), monitor(3C), attributes(5), prof(5) Graham,. mkmsgs(1), srchtxt(1), gettxt(3C), setlocale(3C), attributes(5), environ(5) gettxt(1) FILES ATTRIBUTES SEE ALSO 506 man pages section 1: User Commands • Last Revised 20 Dec 199 6 glob – shell built-in. printf(1), gettext(3C), setlocale(3C), attributes(5) This is the shell equivalent of the library routine gettext(3C). gettext(1) ATTRIBUTES SEE ALSO NOTES 504 man pages section 1: User Commands • Last

Ngày đăng: 24/07/2014, 02:20

TỪ KHÓA LIÊN QUAN