The K Shell Program Guide (1)

xiaoxiao2021-03-06  85

1)

WildcardMatches? Any Single Character * Any STRING OF CHARACTERS [SET] Any Character In Set [! Set] Any Character Not in Set2)

ExpressionMatches [ABC] A, B, or C [.,;] Period, Comma, or SEMICOLON [-_] Dash and undreScore [AC] A, B, or C [AZ] All LowerCase Letters [! 0-9] All Non-Digits [0-9!] All Digits and Exclamation Point [A-ZA-Z] All Lower- and Uppercase Letters [A-ZA-Z0-9 _-] all letters, all digits, underscore, and dash3)

UtilityPurposecatCopy input to outputgrepSearch for strings in the inputsortSort lines in the inputcutExtract columns from inputsedPerform editing operations on inputtrTranslate characters in the input to other characters4)

FC -L

FC -E - Number

5)

User's environment file is .profile.

6) Built-in Commands and Keywords

Here Is A Summary of All Built-in Commands and Keywords.

CommandChapterSummary: 7Do nothing (just do expansions of arguments) .. 4Read file and execute its contents in current shell.alias3Set up shorthand for command or command line.bg8Put job in background.break5 Exit from surrounding for, select, while, or until loop .case5Multi-way conditional construct.cd1Change working directory.continue Skip to next iteration of for, select, while, or until loop.echo4Expand and print arguments (obsolete) .exec9Replace shell with given program.exit5Exit from shell.export3Create environment variables.eval7Process arguments as a command line.fc2Fix command (edit history file) .fg8Put background job in foreground.for5Looping construct.function4Define function.getopts6Process command-line options.if5Conditional construct.jobs1List background jobs.kill8Send signal to process.let6Arithmetic variable assignment.newgrpStart new Shell with new group id.print1expand and print arguments on standard output.pwd1print Working Directory.Read7read a line from Standard Input. readonly6Make variables read-only (unassignable) .return5Return from surrounding function or script.select5Menu generation construct.set3Set options. shift6Shift command-line arguments.timeRun command and print execution times.trap8Set up signal-catching routine.typeset6Set special characteristics of variables.ulimit10Set / show process resource limits.umask10Set / show file permission mask.unalias3Remove alias definitions.unset3Remove definitions of variables or functions.until5Looping construct.wait8Wait for background job (s) to finish.whence3Identify source of command.while5Looping construct.7) Built-in Shell Variables

VariableChapterMeaning # 4Number of arguments given to current process.-Options given to shell on invocation.?5Exit status of previous command. $ 8Process ID of shell process._Last argument to previous command.! 8Process ID of last background command.CDPATH3List of directories for cd command to search.COLUMNS3 Width of display in columns (for editing modes and select) .EDITOR2 Used to set editing mode; also used by mail and other programs.ERRNOAError number of last system call that failed.ENV3 Name of file to run as environment file when shell is invoked.FCEDIT2Default editor for fc command.FPATH4Search path for autoloaded functions.IFS7 Internal field separator: list of characters that act as word separators Normally set to SPACE, TAB, and NEWLINE.HISTFILE2Name of command history file.HISTSIZE2Number. Of Lines Kept in History File.home3Home (Login) Directory.Lineno9Number of Line In Script or Function That Just Ran.Lines3Height of Display In lines (for select command) .mail3name of file to c heck for new mail.MAILCHECK3How often (in seconds) to check for new mail.MAILPATH3 List of file names to check for new mail, if MAIL is not set.OLDPWD3Previous working directory.OPTARG6Argument to option being processed by getopts.OPTIND6Number of first argument after options.PATH3Search path for commands.PS13Primary command prompt string.PS23Prompt string for line continuations.PS35Prompt string for select command. PS49Prompt string for xtrace option.PPID8Process ID of parent process.PWD3Current working directory.RANDOM9 Random number between 0 and 32767 (2215 -1) .reply5,7 user's response to select commnd;

result of read command if no variable names given.SECONDS3Number of seconds since shell was invoked.SHELL3Full pathname of shell.TMOUT10 If set to a positive integer, number of seconds between commands after which shell automatically terminates.VISUAL2Used to set editing mode.8) Test Operators

THESE ARE THE OPERATORS THATER Used with the [[...]] construct. They can be logically combined with | and || ("or") and groups.

OperatorTrue if ...- A FileFile Exists.-b FileFile IS A BLOCK Device File.-c FileFile IS A Character Device File.-D FileFile IS A Directory.-F FileFile Is A Regular File.-G FileFile Has ITS setgid bit SET.-K Filefile Has ITS Sticky Bit Set.-N StringString IS NON-NULL.-O OptionOption IS SET.-P FileFile Is A Pipe or Named Pipe (FIFO File). - R FileFile Is Readable.-S FileFile IS NOT EMPTY.-T NFILE DESCRIPTOR N POINTS TO A TERMINAL.-U FILEFILE HAS ITS SETUID BIT.-W FileFile IS Writeable.-x File File File File File File IS Executable, or File Is A Directory That Can Be Searched.-z stringstring is null. -G filefile's group id is the same as this of the shell. -l filefile isot, one, s, s, s,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, hardcore -ot fileBfileA is older than fileB.fileA -ef fileB fileA and fileB point to the same file.string = pattern string matches pattern (which can contain wildcards) .string! = patternstring does not match pattern.string A stringB stringA comes after stringB in dictionary order.exprA -eq exprB Arithmetic expressions exprA and exprB are equal.exprA -ne exprB Arithmetic expressions exprA and exprB are not equal.exprA -lt exprBexprA is less than exprB.exprA -gt exprBexprA is greater than exprB.exprA -le exprBexprA is less than or equal to exprB.exprA -ge exprBexprA is greater than or equal to exprB.9) Typeset Options

The Thepeset Command.

OptionMeaningWith no option, create local variable within function.-LLeft justify and remove leading blanks.-RRight justify and remove trailing blanks.-fWith no arguments, prints all function definitions.-f fnamePrints the definition of function fname. FPrints all function names .-ftTurns on trace mode for named function (s). ftTurns off trace mode for named function (s) .- fuDefines given name (s) as autoloaded function (s) .- iDeclare variable as an integer.-lConvert all letters To LowerCase.-Rmake Variable Read-Only.-Uconvert All Letters to Uppercase.-x Export Variable, IE, PUT IN ENVIRONMENT SO THAT IT IS Passed To Subshells10)

Substitution Operators

转载请注明原文地址:https://www.9cbs.com/read-105937.html

New Post(0)