Sie sind auf Seite 1von 4

Survival guide to the Unix shell tcsh Command syntax Every Unix command has a name, a set of options,

and a set of arguments: name options arguments Options are normally preceded by a minus sign - to distinguish them from arguments. A list of common Unix commands is given in the attached table. Files and directories / . .. name /f/g/h/name Root of le system Home directory Current (or working) directory Parent of current directory File name in current directory Full path (le) name

The most important le processing commands are: ls, more, mv, cp, rm. The most important directory processing commands are: pwd, cd, mkdir, rmdir File permissions Every le has a type, an owner, a group and a set of permissions. The main le types are plain (text) les and directories. Every le may have read/write/execute permission for user (owner), group and other users. These are displayed by the ls -l command and changed by the chmod command. Directories can be stacked: dirs pushd dir pushd +n pushd popd Display directory stack Push and move to directory dir Move to nth directory on stack Exchange top and previous directory on stack Pop to previous directory on stack

cd changes top directory on stack. Filename expansion Sets of le names may be abbreviated: * ? [string] {string1,string2,...} Autocompletion Pressing TAB while entering a le name automatically completes the le name. If there are more than one possible completion, it beeps. To see the possible completions, type D. Then type one or more characters, and press TAB again. Any string of characters Any single character Any character in string The given set of (sub)strings

File redirection command command command command < from > to >> to >& to command reads standard input from le from. command writes standard output to le to, overwriting old le to command appends standard output to le to command writes stdout and stderr to le to

(This last construct also works for appending and piping (below); just add an "&" character after ">>" or "|".) Command composition command1 ; command2 command1 | command2 Job control command & Z stop %n kill %n fg %n bg %n jobs History mechanism history !! !m !cmd ! !$ !* oldnew Display last n commands Repeat previous command Repeat command m Repeat last command starting with string cmd First argument (or option) of previous command Last argument of previous command All arguments of previous command Repeat previous command with string old replaced by string new Execute command in background Suspend foreground process (job) Suspend background job n Terminate background job n Resume job n in foreground Resume job n in background Display current jobs Execute command1 then command2 Pipe standard output from command1 to standard input of command2

Previous commands may also be found, edited, and executed using the up/down arrow keys. .cshrc Commands can be renamed and new commands dened: alias name command The command may contain ;, |, !* (as above). For example: alias m more alias ll ls -l \!* | more Many variables can be dened, for example: set ignoreeof notify nonomatch set autocorrect autoexpand autolist correct=all dunique recexact rmstar set printexitvalue It is normal to put such denitions in the le /.cshrc.

Regular expressions These are used by grep, sed, ed, vi, and many other commands. . $ c [string] [string] e* e+ \(e\) \n e1 e2 Control characters DELETE W U R S/Q C Z D Common Unix commands man command ls ls le ... -a -d -g -l -t file le ... cp le1 le2 ln le1 le2 ln -s le1 le2 mv le1 le2 rm le ... cp/mv/rm -i le ... chmod int le ... pwd Display manual entry for command List (display) names of all les in current directory List named les or les in named directories. Options follow: List all, including les whose names start with . List (as) directory, not les in directory List group of les List long, more information List in time order, most recent rst Display (estimated) type of named les Copy le1 to le2, overwrite old le2 if it exists Link le1 to le2 (le1 and le2 are now aliases) Symbolic link from le1 (a directory) to le2 Move (rename) le1 to le2, overwrite old le2 if it exists Remove named les, irrevocably Overwrite/remove named les only after conrmation Change permission of named les Print working (current) directory Delete (or rubout) last character typed Delete last word typed Delete last line typed Redraw current line Suspend/resume output to screen Terminate current process Suspend current process End of (standard input) le Any character Start of line End of line Character c Any character in string, e.g., [a-zA-Z0-9] Any character not in string 0 or more occurences of the regular expression e 1 or more occurences of the regular expression e Regular expression e Bracketed regular expression starting with nth \( Regular expression e1 followed by regular expression e2

cd dir mkdir dir rmdir dir pushd dir/popd/dirs ed le vi le cat le ... more le ... less le ... head le head -n le tail le tail +n le pr le ... pr -n le ... lpr le ... lpq lprm job lpr/lpq/lprm -Pprinter awk commands le ... bc cal month year cmp le1 le2 date diff le1 le2 fmt le ... grep pattern le ... logout mail mail user passwd pine sed commands le ... sed -f program le ... set variable [= value] sort le ... stty ... tr string1 string2 wc le ... who

Change (move) to named directory Make a new named directory Remove named directory, irrevocably Push/pop/display directories on stack Edit named le Visually edit named le Concatenate (display) contents of named les Display contents of named les, a screen at a time Less is more, enables backward movement in les Display rst 10 lines of named le Display rst n lines of named le Display last 10 lines of named le Start displaying at line n Display contents of named les with headers Display contents of named les with headers in n columns Print contents of named les (text les only!) Display printer status Remove job from printer queue Use named printer Apply awk commands to named les Arbitrary precision arithmetic calculator Display calendar for given month and year Compare named les Display current date and time Display all differences between named les Format named les Print lines of named les matching pattern Terminate session Read mail Send mail to user Change your password A user-friendly mail client Stream editor: apply ed commands to named les Apply commands in le program to named les Set or assign shell variable Sort named les alphabetically by line Set terminal characteristics Copy standard input to standard output, translating all chars in string1 into corresponding chars in string2 Count lines, words and characters of named les Display who is using the machine

Das könnte Ihnen auch gefallen