⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csh.1

📁 早期freebsd实现
💻 1
📖 第 1 页 / 共 3 页
字号:
beginning are treated specially.Neither `*' or `?' or the `[' `]' mechanism will match it.This prevents accidental matching of the filenames `.' and `..'in the working directory which have special meaning to the system,as well as other files such as .I \&.cshrcwhich are not normallyvisible.We will discuss the special role of the file.I \&.cshrclater..PPAnother filename expansion mechanism gives access to the pathname ofthe.I homedirectory of other users.This notation consists of the character `~' (tilde) followed by another user'slogin name.For instance the word `~bill' would map to the pathname `/usr/bill'if the home directory for `bill' was `/usr/bill'.Since, on large systems, users may have login directories scattered overmany different disk volumes with different prefix directory names,this notation provides a convenient way of accessing the filesof other users..PPA special case of this notation consists of a `~' alone, e.g. `~/mbox'.This notation is expanded by the shell into the file `mbox' in your.I homedirectory, i.e. into `/usr/bill/mbox' for me on Ernie Co-vax, the UCBComputer Science Department VAX machine, where this document was prepared.This can be very useful if you have used.I cdto change to another directory and have found a file you wish tocopy using.I cp.If I give the command.DScp thatfile ~.DEthe shell will expand this command to.DScp thatfile /usr/bill.DEsince my home directory is /usr/bill..PPThere also exists a mechanism using the characters `{' and `}' forabbreviating a set of words which have common parts but cannotbe abbreviated by the above mechanisms because they are not files,are the names of files which do not yet exist,are not thus conveniently described.This mechanism will be described much later,in section 4.2,as it is used less frequently..NH 2Quotation.PPWe have already seen a number of metacharacters used by the shell.These metacharacters pose a problem in that we cannot use them directly as parts of words.Thus the command.DSecho *.DEwill not echo the character `*'.It will either echo an sorted list of filenames in thecurrent.I "working directory,"or print the message `No match' if there are no files in the working directory..PPThe recommended mechanism for placing characters which are neither numbers,digits, `/', `.' or `\-' in an argument word to a command is to encloseit with single quotation characters `\'', i.e..DSecho \'*\'.DEThere is one special character `!' which is used by the.I historymechanism of the shell and which cannot be.I escapedby placing it within `\'' characters.It and the character `\'' itself can be preceded by a single `\e'to prevent their special meaning.Thus.DSecho \e\'\e!.DEprints.DS\'!.DEThese two mechanisms suffice to place any printing character into a wordwhich is an argument to a shell command.  They can be combined, as in.DSecho \e\'\'*\'.DEwhich prints.DS\'*.DEsince the first `\e' escaped the first `\'' and the `*' was enclosedbetween `\'' characters..NH 2Terminating commands.PPWhen you are executing a command and the shell iswaiting for it to complete there are several waysto force it to stop.For instance if you type the command.DScat /etc/passwd.DEthe system will print a copy of a list of all users of the systemon your terminal.This is likely to continue for several minutes unless you stop it.You can send an\s-2INTERRUPT\s0.I signalto the.I catcommand by typing ^C on your terminal.*.FS*On some older Unix systems the \s-2DEL\s0 or \s-2RUBOUT\s0 keyhas the same effect. "stty all" will tell you the INTR key value..FESince.I catdoes not take any precautions to avoid or otherwise handle this signalthe\s-2INTERRUPT\s0will cause it to terminate.The shell notices that.I cathas terminated and prompts you again with `% '.If you hit \s-2INTERRUPT\s0 again, the shell will justrepeat its prompt since it handles \s-2INTERRUPT\s0 signalsand chooses to continue to execute commands rather than terminatinglike.I catdid, which would have the effect of logging you out..PPAnother way in which many programs terminate is when they get an end-of-filefrom their standard input.Thus the.I mailprogram in the first example above was terminated when we typed a ^Dwhich generates an end-of-file from the standard input.The shell also terminates when it gets an end-of-file printing `logout';\s-2UNIX\s0 then logs you off the system.Since this means that typing too many ^D's can accidentally log us off,the shell has a mechanism for preventing this.This .I ignoreeofoption will be discussed in section 2.2..PPIf a command has its standard input redirected from a file, then it willnormally terminate when it reaches the end of this file.Thus if we execute.DSmail bill < prepared.text.DEthe mail command will terminate without our typing a ^D.This is because it read to the end-of-file of our file`prepared.text' in which we placed a message for `bill' with an editor program.We could also have done.DScat prepared.text \||\| mail bill.DEsince the.I catcommand would then have written the text through the pipe to thestandard input of the mail command.When the.I catcommand completed it would have terminated,closing down the pipelineand the.I mailcommand would have received an end-of-file from it and terminated.Using a pipe here is more complicated than redirecting inputso we would more likely use the first form.These commands could also have been stopped by sending an \s-2INTERRUPT\s0..PPAnother possibility for stopping a command is to suspend its executiontemporarily, with the possibility of continuing execution later.  This isdone by sending a \s-2STOP\s0 signal via typing a ^Z.This signal causes all commands running on the terminal(usually one but more if a pipeline is executing) to become suspended.The shell notices that the command(s) have been suspended, types`Stopped' and then prompts for a new command.The previously executing command has been suspended, but otherwiseunaffected by the \s-2STOP\s0 signal.  Any other commands can be executedwhile the original command remains suspended.  The suspended command canbe continued using the.I fgcommand with no arguments.  The shell will then retype the commandto remind you which command is being continued, and cause the commandto resume execution.  Unless any input files in use by the suspendedcommand have been changed in the meantime, the suspension has no effectwhatsoever on the execution of the command.  This feature can be very usefulduring editing, when you need to look at another file before continuing. Anexample of command suspension follows..DS% mail haroldSomeone just copied a big file into my directory and its name is^ZStopped% lsfunnyfileprog.cprog.o% jobs.ta 1.75i[1]  + Stopped	mail harold% fgmail haroldfunnyfile. Do you know who did it?EOT%.so tabs.DEIn this example someone was sending a message to Harold and forgot thename of the file he wanted to mention.  The mail command was suspendedby typing ^Z.  When the shell noticed that the mail program wassuspended, it typed `Stopped' and prompted for a new command.  Then the.I lscommand was typed to find out the name of the file.  The.I jobscommand was run to find out which command was suspended. At this time the.I fgcommand was typed to continue execution of the mail program.  Inputto the mail program was then continued and ended with a ^Dwhich indicated the end of the message at which time the mailprogram typed EOT.  The.I jobscommand will show which commands are suspended.The ^Z should only be typed at the beginning of a line sinceeverything typed on the current line is discarded when a signal is sentfrom the keyboard.  This also happens on \s-2INTERRUPT\s0, and \s-2QUIT\s0signals.  More information onsuspending jobs and controlling them is given insection 2.6..PPIf you write or run programs which are not fully debugged then it maybe necessary to stop them somewhat ungracefully.This can be done by sending them a \s-2QUIT\s0signal, sent by typing a ^\e.This will usually provoke the shell to produce a message like:.DSQuit (Core dumped).DEindicating that a file`core' has been created containing information about the running program'sstate when it terminated due to the \s-2QUIT\s0 signal.You can examine this file yourself, or forward information to themaintainer of the program telling him/her where the.I "core file"is..PPIf you run background commands (as explained in section 2.6) then thesecommands will ignore \s-2INTERRUPT\s0 and \s-2QUIT\s0 signals at theterminal.  To stop them you must use the.I killcommand.  See section 2.6 for an example..PPIf you want to examine the output of a command without having it moveoff the screen as the output of the.DScat /etc/passwd.DEcommand will, you can use the command.DSmore /etc/passwd.DEThe.I moreprogram pauses after each complete screenful and types `\-\-More\-\-'at which point you can hit a space to get another screenful, a returnto get another line, a `?' to get some help on other commands, or a `q' to end the.I moreprogram.  You can also use more as a filter, i.e..DScat /etc/passwd | more.DEworks just like the more simple more command above..PPFor stopping output of commands not involving.I moreyou can use the^S key to stop the typeout.  The typeout will resume when youhit ^Q or any other key, but ^Q is normally used becauseit only restarts the output and does not become input to the programwhich is running.  This works well on low-speed terminals, but at 9600baud it is hard to type ^S and ^Q fast enough to paginatethe output nicely, and a program like.I moreis usually used..PPAn additional possibility is to use the ^O flush outputcharacter; when this character is typed, all output from the currentcommand is thrown away (quickly) until the next input read occursor until the next shell prompt.  This can be used to allow a commandto complete without having to suffer through the output on a slowterminal; ^O is a toggle, so flushing can be turned off bytyping ^O again while output is being flushed..NH 2What now?.PPWe have so far seen a number of mechanisms of the shell and learned a lotabout the way in which it operates.The remaining sections will go yet further into the internals of theshell, but you will surely want to try using theshell before you go any further.To try it you can log in to \s-2UNIX\s0 and type the followingcommand to the system:.DSchsh myname /bin/csh.DEHere `myname' should be replaced by the name you typed tothe system prompt of `login:' to get onto the system.Thus I would use `chsh bill /bin/csh'..BYou only have to do this once; it takes effect at next login..RYou are now ready to try using.I csh..PPBefore you do the `chsh' command, the shell you are using whenyou log into the system is `/bin/sh'.In fact, much of the above discussion is applicable to `/bin/sh'.The next section will introduce many features particular to.I cshso you should change your shell to.I cshbefore you begin reading it..bp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -