Você está na página 1de 43

10/24/2015

cshLinuxCommandUnixCommand

Tech

Linux

Share

Linux/UnixCommand:csh
CommandLibrary
NAME
tcshCshellwithfilenamecompletionandcommandlineediting
SYNOPSIS
tcsh[bcdefFimnqstvVxX][Dname[=value]][arg...]
tcshl
DESCRIPTION
tcshisanenhancedbutcompletelycompatibleversionoftheBerkeleyUNIXCshell,csh(1).Itisacommandlanguageinterpreterusablebothasaninteractive
loginshellandashellscriptcommandprocessor.Itincludesacommandlineeditor(seeThecommandlineeditor),programmablewordcompletion(see
Completionandlisting),spellingcorrection(seeSpellingcorrection),ahistorymechanism(seeHistorysubstitution),jobcontrol(seeJobs)andaClike
syntax.TheNEWFEATURESsectiondescribesmajorenhancementsoftcshovercsh(1).Throughoutthismanual,featuresoftcshnotfoundinmostcsh(1)
implementations(specifically,the4.4BSDcsh)arelabeledwith`(+)',andfeatureswhicharepresentincsh(1)butnotusuallydocumentedarelabeledwith
`(u)'.
Argumentlistprocessing
Ifthefirstargument(argument0)totheshellis`'thenitisaloginshell.Aloginshellcanbealsospecifiedbyinvokingtheshellwiththelflagastheonly
argument.
Therestoftheflagargumentsareinterpretedasfollows:
b
Forcesa``break''fromoptionprocessing,causinganyfurthershellargumentstobetreatedasnonoptionarguments.Theremainingargumentswillnot
beinterpretedasshelloptions.Thismaybeusedtopassoptionstoashellscriptwithoutconfusionorpossiblesubterfuge.Theshellwillnotrunaset
userIDscriptwithoutthisoption.
c
Commandsarereadfromthefollowingargument(whichmustbepresent,andmustbeasingleargument),storedinthecommandshellvariablefor
reference,andexecuted.Anyremainingargumentsareplacedintheargvshellvariable.
d
Theshellloadsthedirectorystackfrom~/.cshdirsasdescribedunderStartupandshutdown,whetherornotitisaloginshell.(+)
Dname[=value]
Setstheenvironmentvariablenametovalue.(Domain/OSonly)(+)
e
Theshellexitsifanyinvokedcommandterminatesabnormallyoryieldsanonzeroexitstatus.
f
Theshellignores~/.tcshrc,andthusstartsfaster.
F
Theshellusesfork(2)insteadofvfork(2)tospawnprocesses.(Convex/OSonly)(+)
i
Theshellisinteractiveandpromptsforitstoplevelinput,evenifitappearstonotbeaterminal.Shellsareinteractivewithoutthisoptioniftheirinputs
andoutputsareterminals.
l
Theshellisaloginshell.Applicableonlyiflistheonlyflagspecified.
m
Theshellloads~/.tcshrcevenifitdoesnotbelongtotheeffectiveuser.Newerversionsofsu(1)canpassmtotheshell.(+)

http://linux.about.com/library/cmd/blcmdl1_csh.htm

1/43

10/24/2015

cshLinuxCommandUnixCommand

n
Theshellparsescommandsbutdoesnotexecutethem.Thisaidsindebuggingshellscripts.
q
TheshellacceptsSIGQUIT(seeSignalhandling)andbehaveswhenitisusedunderadebugger.Jobcontrolisdisabled.(u)
s
Commandinputistakenfromthestandardinput.
t
Theshellreadsandexecutesasinglelineofinput.A`\'maybeusedtoescapethenewlineattheendofthislineandcontinueontoanotherline.
v
Setstheverboseshellvariable,sothatcommandinputisechoedafterhistorysubstitution.
x
Setstheechoshellvariable,sothatcommandsareechoedimmediatelybeforeexecution.
V
Setstheverboseshellvariableevenbeforeexecuting~/.tcshrc.
X
IstoxasVistov.
Afterprocessingofflagarguments,ifargumentsremainbutnoneofthec,i,s,ortoptionsweregiven,thefirstargumentistakenasthenameofafileof
commands,or``script'',tobeexecuted.Theshellopensthisfileandsavesitsnameforpossibleresubstitutionby`$0'.Becausemanysystemsuseeitherthe
standardversion6orversion7shellswhoseshellscriptsarenotcompatiblewiththisshell,theshellusessucha`standard'shelltoexecuteascriptwhosefirst
characterisnota`#',i.e.,thatdoesnotstartwithacomment.
Remainingargumentsareplacedintheargvshellvariable.
Startupandshutdown
Aloginshellbeginsbyexecutingcommandsfromthesystemfiles/etc/csh.cshrcand/etc/csh.login.Itthenexecutescommandsfromfilesintheuser'shome
directory:first~/.tcshrc(+)or,if~/.tcshrcisnotfound,~/.cshrc,then~/.history(orthevalueofthehistfileshellvariable),then~/.login,andfinally
~/.cshdirs(orthevalueofthedirsfileshellvariable)(+).Theshellmayread/etc/csh.loginbeforeinsteadofafter/etc/csh.cshrc,and~/.loginbeforeinsteadof
after~/.tcshrcor~/.cshrcand~/.history,ifsocompiledseetheversionshellvariable.(+)
Nonloginshellsreadonly/etc/csh.cshrcand~/.tcshrcor~/.cshrconstartup.
Forexamplesofstartupfiles,pleaseconsulthttp://tcshrc.sourceforge.net.
Commandslikestty(1)andtset(1),whichneedberunonlyonceperlogin,usuallygoinone's~/.loginfile.Userswhoneedtousethesamesetoffileswith
bothcsh(1)andtcshcanhaveonlya~/.cshrcwhichchecksfortheexistenceofthetcshshellvariable(q.v.)beforeusingtcshspecificcommands,orcanhave
botha~/.cshrcanda~/.tcshrcwhichsources(seethebuiltincommand)~/.cshrc.Therestofthismanualuses`~/.tcshrc'tomean`~/.tcshrcor,if~/.tcshrc
isnotfound,~/.cshrc'.
Inthenormalcase,theshellbeginsreadingcommandsfromtheterminal,promptingwith`>'.(Processingofargumentsandtheuseoftheshelltoprocess
filescontainingcommandscriptsaredescribedlater.)Theshellrepeatedlyreadsalineofcommandinput,breaksitintowords,placesitonthecommand
historylist,parsesitandexecuteseachcommandintheline.
Onecanlogoutbytyping`^D'onanemptyline,`logout'or`login'orviatheshell'sautologoutmechanism(seetheautologoutshellvariable).Whenalogin
shellterminatesitsetsthelogoutshellvariableto`normal'or`automatic'asappropriate,thenexecutescommandsfromthefiles/etc/csh.logoutand
~/.logout.TheshellmaydropDTRonlogoutifsocompiledseetheversionshellvariable.
Thenamesofthesystemloginandlogoutfilesvaryfromsystemtosystemforcompatibilitywithdifferentcsh(1)variantsseeFILES.
Editing
WefirstdescribeThecommandlineeditor.TheCompletionandlistingandSpellingcorrectionsectionsdescribetwosetsoffunctionalitythatare
implementedaseditorcommandsbutwhichdeservetheirowntreatment.Finally,Editorcommandslistsanddescribestheeditorcommandsspecifictothe
shellandtheirdefaultbindings.
Thecommandlineeditor(+)
CommandlineinputcanbeeditedusingkeysequencesmuchlikethoseusedinGNUEmacsorvi(1).Theeditorisactiveonlywhentheeditshellvariableis
set,whichitisbydefaultininteractiveshells.Thebindkeybuiltincandisplayandchangekeybindings.Emacsstylekeybindingsareusedbydefault(unless
theshellwascompiledotherwiseseetheversionshellvariable),butbindkeycanchangethekeybindingstovistylebindingsenmasse.
Theshellalwaysbindsthearrowkeys(asdefinedintheTERMCAPenvironmentvariable)to
down

http://linux.about.com/library/cmd/blcmdl1_csh.htm

2/43

10/24/2015

cshLinuxCommandUnixCommand
downhistory

up
uphistory
left
backwardchar
right
forwardchar
unlessdoingsowouldalteranothersinglecharacterbinding.Onecansetthearrowkeyescapesequencestotheemptystringwithsettctopreventthese
bindings.TheANSI/VT100sequencesforarrowkeysarealwaysbound.
Otherkeybindingsare,forthemostpart,whatEmacsandvi(1)userswouldexpectandcaneasilybedisplayedbybindkey,sothereisnoneedtolistthem
here.Likewise,bindkeycanlisttheeditorcommandswithashortdescriptionofeach.
Notethateditorcommandsdonothavethesamenotionofa``word''asdoestheshell.Theeditordelimitswordswithanynonalphanumericcharactersnot
intheshellvariablewordchars,whiletheshellrecognizesonlywhitespaceandsomeofthecharacterswithspecialmeaningstoit,listedunderLexical
structure.
Completionandlisting(+)
Theshellisoftenabletocompletewordswhengivenauniqueabbreviation.Typepartofaword(forexample`ls/usr/lost')andhitthetabkeytorunthe
completewordeditorcommand.Theshellcompletesthefilename`/usr/lost'to`/usr/lost+found/',replacingtheincompletewordwiththecompletewordin
theinputbuffer.(Notetheterminal`/'completionaddsa`/'totheendofcompleteddirectoriesandaspacetotheendofothercompletedwords,tospeed
typingandprovideavisualindicatorofsuccessfulcompletion.Theaddsuffixshellvariablecanbeunsettopreventthis.)Ifnomatchisfound(perhaps
`/usr/lost+found'doesn'texist),theterminalbellrings.Ifthewordisalreadycomplete(perhapsthereisa`/usr/lost'onyoursystem,orperhapsyouwere
thinkingtoofaraheadandtypedthewholething)a`/'orspaceisaddedtotheendifitisn'talreadythere.
Completionworksanywhereintheline,notatjusttheendcompletedtextpushestherestofthelinetotheright.Completioninthemiddleofawordoften
resultsinleftovercharacterstotherightofthecursorthatneedtobedeleted.
Commandsandvariablescanbecompletedinmuchthesameway.Forexample,typing`em[tab]'wouldcomplete`em'to`emacs'ifemacsweretheonly
commandonyoursystembeginningwith`em'.Completioncanfindacommandinanydirectoryinpathorifgivenafullpathname.Typing`echo$ar[tab]'
wouldcomplete`$ar'to`$argv'ifnoothervariablebeganwith`ar'.
Theshellparsestheinputbuffertodeterminewhetherthewordyouwanttocompleteshouldbecompletedasafilename,commandorvariable.Thefirstword
inthebufferandthefirstwordfollowing`',`|',`|&',`&&'or`||'isconsideredtobeacommand.Awordbeginningwith`$'isconsideredtobeavariable.
Anythingelseisafilename.Anemptylineis`completed'asafilename.
Youcanlistthepossiblecompletionsofawordatanytimebytyping`^D'torunthedeletecharorlistoreofeditorcommand.Theshellliststhepossible
completionsusingthelsFbuiltin(q.v.)andreprintsthepromptandunfinishedcommandline,forexample:
>ls/usr/l[^D]
lbin/lib/local/lost+found/
>ls/usr/l
Iftheautolistshellvariableisset,theshellliststheremainingchoices(ifany)whenevercompletionfails:
>setautolist
>nm/usr/lib/libt[tab]
libtermcap.a@libtermlib.a@
>nm/usr/lib/libterm
Ifautolistissetto`ambiguous',choicesarelistedonlywhencompletionfailsandaddsnonewcharacterstothewordbeingcompleted.
Afilenametobecompletedcancontainvariables,yourownorothers'homedirectoriesabbreviatedwith`~'(seeFilenamesubstitution)anddirectorystack
entriesabbreviatedwith`='(seeDirectorystacksubstitution).Forexample,
>ls~k[^D]
kahnkaskellogg
>ls~ke[tab]
>ls~kellogg/
or
>setlocal=/usr/local
>ls$lo[tab]
>ls$local/[^D]
bin/etc/lib/man/src/
>ls$local/

http://linux.about.com/library/cmd/blcmdl1_csh.htm

3/43

10/24/2015

cshLinuxCommandUnixCommand

Notethatvariablescanalsobeexpandedexplicitlywiththeexpandvariableseditorcommand.
deletecharorlistoreoflistsatonlytheendofthelineinthemiddleofalineitdeletesthecharacterunderthecursorandonanemptylineitlogsoneout
or,ifignoreeofisset,doesnothing.`M^D',boundtotheeditorcommandlistchoices,listscompletionpossibilitiesanywhereonaline,andlistchoices(or
anyoneoftherelatededitorcommandsthatdoordon'tdelete,listand/orlogout,listedunderdeletecharorlistoreof)canbeboundto`^D'withthe
bindkeybuiltincommandifsodesired.
Thecompletewordfwdandcompletewordbackeditorcommands(notboundtoanykeysbydefault)canbeusedtocycleupanddownthroughthelistof
possiblecompletions,replacingthecurrentwordwiththenextorpreviouswordinthelist.
Theshellvariablefignorecanbesettoalistofsuffixestobeignoredbycompletion.Considerthefollowing:
>ls
Makefilecondiments.h~main.oside.c
READMEmain.cmealside.o
condiments.hmain.c~
>setfignore=(.o\~)
>emacsma[^D]
main.cmain.c~main.o
>emacsma[tab]
>emacsmain.c
`main.c~'and`main.o'areignoredbycompletion(butnotlisting),becausetheyendinsuffixesinfignore.Notethata`\'wasneededinfrontof`~'to
preventitfrombeingexpandedtohomeasdescribedunderFilenamesubstitution.fignoreisignoredifonlyonecompletionispossible.
Ifthecompleteshellvariableissetto`enhance',completion1)ignorescaseand2)considersperiods,hyphensandunderscores(`.',`'and`_')tobeword
separatorsandhyphensandunderscorestobeequivalent.Ifyouhadthefollowingfiles
comp.lang.ccomp.lang.perlcomp.std.c++
comp.lang.c++comp.std.c
andtyped`mailfc.l.c[tab]',itwouldbecompletedto`mailfcomp.lang.c',and^Dwouldlist`comp.lang.c'and`comp.lang.c++'.`mailfc..c++[^D]'would
list`comp.lang.c++'and`comp.std.c++'.Typing`rmafile[^D]'inthefollowingdirectory
A_silly_fileahyphenatedfileanother_silly_file
wouldlistallthreefiles,becausecaseisignoredandhyphensandunderscoresareequivalent.Periods,however,arenotequivalenttohyphensorunderscores.
Completionandlistingareaffectedbyseveralothershellvariables:recexactcanbesettocompleteontheshortestpossibleuniquematch,evenifmore
typingmightresultinalongermatch:
>ls
fodderfoofoodfoonly
>setrecexact
>rmfo[tab]
justbeeps,because`fo'couldexpandto`fod'or`foo',butifwetypeanother`o',
>rmfoo[tab]
>rmfoo
thecompletioncompleteson`foo',eventhough`food'and`foonly'alsomatch.autoexpandcanbesettoruntheexpandhistoryeditorcommandbefore
eachcompletionattempt,autocorrectcanbesettospellingcorrectthewordtobecompleted(seeSpellingcorrection)beforeeachcompletionattemptand
correctcanbesettocompletecommandsautomaticallyafteronehits`return'.matchbeepcanbesettomakecompletionbeepornotbeepinavarietyof
situations,andnobeepcanbesettoneverbeepatall.nostatcanbesettoalistofdirectoriesand/orpatternsthatmatchdirectoriestopreventthe
completionmechanismfromstat(2)ingthosedirectories.listmaxandlistmaxrowscanbesettolimitthenumberofitemsandrows(respectively)thatare
listedwithoutaskingfirst.recognize_only_executablescanbesettomaketheshelllistonlyexecutableswhenlistingcommands,butitisquiteslow.
Finally,thecompletebuiltincommandcanbeusedtotelltheshellhowtocompletewordsotherthanfilenames,commandsandvariables.Completionand
listingdonotworkonglobpatterns(seeFilenamesubstitution),butthelistglobandexpandglobeditorcommandsperformequivalentfunctionsforglob
patterns.
Spellingcorrection(+)
Theshellcansometimescorrectthespellingoffilenames,commandsandvariablenamesaswellascompletingandlistingthem.
Individualwordscanbespellingcorrectedwiththespellwordeditorcommand(usuallyboundtoMsandMS)andtheentireinputbufferwithspellline
(usuallyboundtoM$).Thecorrectshellvariablecanbesetto`cmd'tocorrectthecommandnameor`all'tocorrecttheentirelineeachtimereturnis
typed,andautocorrectcanbesettocorrectthewordtobecompletedbeforeeachcompletionattempt.
Whenspellingcorrectionisinvokedinanyofthesewaysandtheshellthinksthatanypartofthecommandlineismisspelled,itpromptswiththecorrected
line:

http://linux.about.com/library/cmd/blcmdl1_csh.htm

4/43

10/24/2015

cshLinuxCommandUnixCommand

>setcorrect=cmd
>lz/usr/bin
CORRECT>ls/usr/bin(y|n|e|a)?
Onecananswer`y'orspacetoexecutethecorrectedline,`e'toleavetheuncorrectedcommandintheinputbuffer,`a'toabortthecommandasif`^C'had
beenhit,andanythingelsetoexecutetheoriginallineunchanged.
Spellingcorrectionrecognizesuserdefinedcompletions(seethecompletebuiltincommand).Ifaninputwordinapositionforwhichacompletionisdefined
resemblesawordinthecompletionlist,spellingcorrectionregistersamisspellingandsuggeststhelatterwordasacorrection.However,iftheinputworddoes
notmatchanyofthepossiblecompletionsforthatposition,spellingcorrectiondoesnotregisteramisspelling.
Likecompletion,spellingcorrectionworksanywhereintheline,pushingtherestofthelinetotherightandpossiblyleavingextracharacterstotherightofthe
cursor.
Beware:spellingcorrectionisnotguaranteedtoworkthewayoneintends,andisprovidedmostlyasanexperimentalfeature.Suggestionsandimprovements
arewelcome.
Editorcommands(+)
`bindkey'listskeybindingsand`bindkeyl'listsandbrieflydescribeseditorcommands.Onlyneworespeciallyinterestingeditorcommandsaredescribedhere.
Seeemacs(1)andvi(1)fordescriptionsofeacheditor'skeybindings.
Thecharacterorcharacterstowhicheachcommandisboundbydefaultisgiveninparentheses.`^character'meansacontrolcharacterand`Mcharacter'a
metacharacter,typedasescapecharacteronterminalswithoutametakey.Casecounts,butcommandsthatareboundtolettersbydefaultareboundto
bothloweranduppercaselettersforconvenience.
completeword(tab)
CompletesawordasdescribedunderCompletionandlisting.
completewordback(notbound)
Likecompletewordfwd,butstepsupfromtheendofthelist.
completewordfwd(notbound)
Replacesthecurrentwordwiththefirstwordinthelistofpossiblecompletions.Mayberepeatedtostepdownthroughthelist.Attheendofthelist,
beepsandrevertstotheincompleteword.
completewordraw(^Xtab)
Likecompleteword,butignoresuserdefinedcompletions.
copyprevword(M^_)
Copiesthepreviouswordinthecurrentlineintotheinputbuffer.Seealsoinsertlastword.
dabbrevexpand(M/)
Expandsthecurrentwordtothemostrecentprecedingoneforwhichthecurrentisaleadingsubstring,wrappingaroundthehistorylist(once)if
necessary.Repeatingdabbrevexpandwithoutanyinterveningtypingchangestothenextpreviouswordetc.,skippingidenticalmatchesmuchlike
historysearchbackwarddoes.
deletechar(notbound)
Deletesthecharacterunderthecursor.Seealsodeletecharorlistoreof.
deletecharoreof(notbound)
Doesdeletecharifthereisacharacterunderthecursororendoffileonanemptyline.Seealsodeletecharorlistoreof.
deletecharorlist(notbound)
Doesdeletecharifthereisacharacterunderthecursororlistchoicesattheendoftheline.Seealsodeletecharorlistoreof.
deletecharorlistoreof(^D)
Doesdeletecharifthereisacharacterunderthecursor,listchoicesattheendofthelineorendoffileonanemptyline.Seealsothosethree
commands,eachofwhichdoesonlyasingleaction,anddeletecharoreof,deletecharorlistandlistoreof,eachofwhichdoesadifferenttwooutof
thethree.
downhistory(downarrow,^N)
Likeuphistory,butstepsdown,stoppingattheoriginalinputline.
endoffile(notbound)
Signalsanendoffile,causingtheshelltoexitunlesstheignoreeofshellvariable(q.v.)issettopreventthis.Seealsodeletecharorlistoreof.
expandhistory(Mspace)
Expandshistorysubstitutionsinthecurrentword.SeeHistorysubstitution.Seealsomagicspace,toggleliteralhistoryandtheautoexpandshell
variable.
expandglob(^X*)

http://linux.about.com/library/cmd/blcmdl1_csh.htm

5/43

10/24/2015

cshLinuxCommandUnixCommand

Expandstheglobpatterntotheleftofthecursor.SeeFilenamesubstitution.
expandline(notbound)
Likeexpandhistory,butexpandshistorysubstitutionsineachwordintheinputbuffer,
expandvariables(^X$)
Expandsthevariabletotheleftofthecursor.SeeVariablesubstitution.
historysearchbackward(Mp,MP)
Searchesbackwardsthroughthehistorylistforacommandbeginningwiththecurrentcontentsoftheinputbufferuptothecursorandcopiesitintothe
inputbuffer.Thesearchstringmaybeaglobpattern(seeFilenamesubstitution)containing`*',`?',`[]'or`{}'.uphistoryanddownhistorywill
proceedfromtheappropriatepointinthehistorylist.Emacsmodeonly.Seealsohistorysearchforwardandisearchback.
historysearchforward(Mn,MN)
Likehistorysearchbackward,butsearchesforward.
isearchback(notbound)
Searchesbackwardlikehistorysearchbackward,copiesthefirstmatchintotheinputbufferwiththecursorpositionedattheendofthepattern,and
promptswith`bck:'andthefirstmatch.Additionalcharactersmaybetypedtoextendthesearch,isearchbackmaybetypedtocontinuesearching
withthesamepattern,wrappingaroundthehistorylistifnecessary,(isearchbackmustbeboundtoasinglecharacterforthistowork)oroneofthe
followingspecialcharactersmaybetyped:
^W
Appendstherestofthewordunderthecursortothesearchpattern.
delete(oranycharacterboundtobackwarddeletechar)
Undoestheeffectofthelastcharactertypedanddeletesacharacterfromthesearchpatternifappropriate.
^G
Iftheprevioussearchwassuccessful,abortstheentiresearch.Ifnot,goesbacktothelastsuccessfulsearch.
escape
Endsthesearch,leavingthecurrentlineintheinputbuffer.
Anyothercharacternotboundtoselfinsertcommandterminatesthesearch,leavingthecurrentlineintheinputbuffer,andistheninterpretedas
normalinput.Inparticular,acarriagereturncausesthecurrentlinetobeexecuted.Emacsmodeonly.Seealsoisearchfwdandhistorysearch
backward.
isearchfwd(notbound)
Likeisearchback,butsearchesforward.
insertlastword(M_)
Insertsthelastwordofthepreviousinputline(`!$')intotheinputbuffer.Seealsocopyprevword.
listchoices(M^D)
ListscompletionpossibilitiesasdescribedunderCompletionandlisting.Seealsodeletecharorlistoreofandlistchoicesraw.
listchoicesraw(^X^D)
Likelistchoices,butignoresuserdefinedcompletions.
listglob(^Xg,^XG)
Lists(viathelsFbuiltin)matchestotheglobpattern(seeFilenamesubstitution)totheleftofthecursor.
listoreof(notbound)
Doeslistchoicesorendoffileonanemptyline.Seealsodeletecharorlistoreof.
magicspace(notbound)
Expandshistorysubstitutionsinthecurrentline,likeexpandhistory,andappendsaspace.magicspaceisdesignedtobeboundtothespacebar,butis
notboundbydefault.
normalizecommand(^X?)
SearchesforthecurrentwordinPATHand,ifitisfound,replacesitwiththefullpathtotheexecutable.Specialcharactersarequoted.Aliasesare
expandedandquotedbutcommandswithinaliasesarenot.Thiscommandisusefulwithcommandsthattakecommandsasarguments,e.g.,`dbx'and
`shx'.
normalizepath(^Xn,^XN)
Expandsthecurrentwordasdescribedunderthe`expand'settingofthesymlinksshellvariable.
overwritemode(unbound)
Togglesbetweeninputandoverwritemodes.
runfgeditor(M^Z)

http://linux.about.com/library/cmd/blcmdl1_csh.htm

6/43

10/24/2015

cshLinuxCommandUnixCommand

SavesthecurrentinputlineandlooksforastoppedjobwithanameequaltothelastcomponentofthefilenamepartoftheEDITORorVISUAL
environmentvariables,or,ifneitherisset,`ed'or`vi'.Ifsuchajobisfound,itisrestartedasif`fg%job'hadbeentyped.Thisisusedtotoggleback
andforthbetweenaneditorandtheshelleasily.Somepeoplebindthiscommandto`^Z'sotheycandothisevenmoreeasily.
runhelp(Mh,MH)
Searchesfordocumentationonthecurrentcommand,usingthesamenotionof`currentcommand'asthecompletionroutines,andprintsit.Thereisno
waytouseapagerrunhelpisdesignedforshorthelpfiles.Ifthespecialaliashelpcommandisdefined,itisrunwiththecommandnameasasole
argument.Else,documentationshouldbeinafilenamedcommand.help,command.1,command.6,command.8orcommand,whichshouldbeinoneof
thedirectorieslistedintheHPATHenvironmentvariable.Ifthereismorethanonehelpfileonlythefirstisprinted.
selfinsertcommand(textcharacters)
Ininsertmode(thedefault),insertsthetypedcharacterintotheinputlineafterthecharacterunderthecursor.Inoverwritemode,replacesthe
characterunderthecursorwiththetypedcharacter.Theinputmodeisnormallypreservedbetweenlines,buttheinputmodeshellvariablecanbeset
to`insert'or`overwrite'toputtheeditorinthatmodeatthebeginningofeachline.Seealsooverwritemode.
sequenceleadin(arrowprefix,metaprefix,^X)
Indicatesthatthefollowingcharactersarepartofamultikeysequence.Bindingacommandtoamultikeysequencereallycreatestwobindings:the
firstcharactertosequenceleadinandthewholesequencetothecommand.Allsequencesbeginningwithacharacterboundtosequenceleadinare
effectivelyboundtoundefinedkeyunlessboundtoanothercommand.
spellline(M$)
Attemptstocorrectthespellingofeachwordintheinputbuffer,likespellword,butignoreswordswhosefirstcharacterisoneof`',`!',`^'or`%',or
whichcontain`\',`*'or`?',toavoidproblemswithswitches,substitutionsandthelike.SeeSpellingcorrection.
spellword(Ms,MS)
AttemptstocorrectthespellingofthecurrentwordasdescribedunderSpellingcorrection.Checkseachcomponentofawordwhichappearstobea
pathname.
toggleliteralhistory(Mr,MR)
Expandsor`unexpands'historysubstitutionsintheinputbuffer.Seealsoexpandhistoryandtheautoexpandshellvariable.
undefinedkey(anyunboundkey)
Beeps.
uphistory(uparrow,^P)
Copiesthepreviousentryinthehistorylistintotheinputbuffer.Ifhistlitisset,usestheliteralformoftheentry.Mayberepeatedtostepupthrough
thehistorylist,stoppingatthetop.
visearchback(?)
Promptswith`?'forasearchstring(whichmaybeaglobpattern,aswithhistorysearchbackward),searchesforitandcopiesitintotheinputbuffer.
Thebellringsifnomatchisfound.Hittingreturnendsthesearchandleavesthelastmatchintheinputbuffer.Hittingescapeendsthesearchand
executesthematch.vimodeonly.
visearchfwd(/)
Likevisearchback,butsearchesforward.
whichcommand(M?)
Doesawhich(seethedescriptionofthebuiltincommand)onthefirstwordoftheinputbuffer.

Lexicalstructure
Theshellsplitsinputlinesintowordsatblanksandtabs.Thespecialcharacters`&',`|',`',`<',`>',`(',and`)'andthedoubledcharacters`&&',`||',`<<'
and`>>'arealwaysseparatewords,whetherornottheyaresurroundedbywhitespace.
Whentheshell'sinputisnotaterminal,thecharacter`#'istakentobeginacomment.Each`#'andtherestoftheinputlineonwhichitappearsisdiscarded
beforefurtherparsing.
Aspecialcharacter(includingablankortab)maybepreventedfromhavingitsspecialmeaning,andpossiblymadepartofanotherword,byprecedingitwitha
backslash(`\')orenclosingitinsingle(`''),double(`"')orbackward(``')quotes.Whennototherwisequotedanewlineprecededbya`\'isequivalenttoa
blank,butinsidequotesthissequenceresultsinanewline.
Furthermore,allSubstitutions(seebelow)exceptHistorysubstitutioncanbepreventedbyenclosingthestrings(orpartsofstrings)inwhichtheyappear
withsinglequotesorbyquotingthecrucialcharacter(s)(e.g.,`$'or``'forVariablesubstitutionorCommandsubstitutionrespectively)with`\'.(Alias
substitutionisnoexception:quotinginanywayanycharacterofawordforwhichanaliashasbeendefinedpreventssubstitutionofthealias.Theusualway
ofquotinganaliasistoprecedeitwithabackslash.)Historysubstitutionispreventedbybackslashesbutnotbysinglequotes.Stringsquotedwithdoubleor
backwardquotesundergoVariablesubstitutionandCommandsubstitution,butothersubstitutionsareprevented.
Textinsidesingleordoublequotesbecomesasingleword(orpartofone).Metacharactersinthesestrings,includingblanksandtabs,donotformseparate
words.Onlyinonespecialcase(seeCommandsubstitutionbelow)canadoublequotedstringyieldpartsofmorethanonewordsinglequotedstringsnever
do.Backwardquotesarespecial:theysignalCommandsubstitution(q.v.),whichmayresultinmorethanoneword.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

7/43

10/24/2015

cshLinuxCommandUnixCommand

Quotingcomplexstrings,particularlystringswhichthemselvescontainquotingcharacters,canbeconfusing.Rememberthatquotesneednotbeusedasthey
areinhumanwriting!Itmaybeeasiertoquotenotanentirestring,butonlythosepartsofthestringwhichneedquoting,usingdifferenttypesofquotingto
dosoifappropriate.
Thebackslash_quoteshellvariable(q.v.)canbesettomakebackslashesalwaysquote`\',`'',and`"'.(+)Thismaymakecomplexquotingtaskseasier,but
itcancausesyntaxerrorsincsh(1)scripts.
Substitutions
Wenowdescribethevarioustransformationstheshellperformsontheinputintheorderinwhichtheyoccur.Wenoteinpassingthedatastructuresinvolved
andthecommandsandvariableswhichaffectthem.RememberthatsubstitutionscanbepreventedbyquotingasdescribedunderLexicalstructure.
Historysubstitution
Eachcommand,or``event'',inputfromtheterminalissavedinthehistorylist.Thepreviouscommandisalwayssaved,andthehistoryshellvariablecanbe
settoanumbertosavethatmanycommands.Thehistdupshellvariablecanbesettonotsaveduplicateeventsorconsecutiveduplicateevents.
Savedcommandsarenumberedsequentiallyfrom1andstampedwiththetime.Itisnotusuallynecessarytouseeventnumbers,butthecurrentevent
numbercanbemadepartofthepromptbyplacingan`!'inthepromptshellvariable.
Theshellactuallysaveshistoryinexpandedandliteral(unexpanded)forms.Ifthehistlitshellvariableisset,commandsthatdisplayandstorehistoryusethe
literalform.
Thehistorybuiltincommandcanprint,storeinafile,restoreandclearthehistorylistatanytime,andthesavehistandhistfileshellvariablescanbecanbe
settostorethehistorylistautomaticallyonlogoutandrestoreitonlogin.
Historysubstitutionsintroducewordsfromthehistorylistintotheinputstream,makingiteasytorepeatcommands,repeatargumentsofaprevious
commandinthecurrentcommand,orfixspellingmistakesinthepreviouscommandwithlittletypingandahighdegreeofconfidence.
Historysubstitutionsbeginwiththecharacter`!'.Theymaybeginanywhereintheinputstream,buttheydonotnest.The`!'maybeprecededbya`\'to
preventitsspecialmeaningforconvenience,a`!'ispassedunchangedwhenitisfollowedbyablank,tab,newline,`='or`('.Historysubstitutionsalsooccur
whenaninputlinebeginswith`^'.Thisspecialabbreviationwillbedescribedlater.Thecharactersusedtosignalhistorysubstitution(`!'and`^')canbe
changedbysettingthehistcharsshellvariable.Anyinputlinewhichcontainsahistorysubstitutionisprintedbeforeitisexecuted.
Ahistorysubstitutionmayhavean``eventspecification'',whichindicatestheeventfromwhichwordsaretobetaken,a``worddesignator'',whichselects
particularwordsfromthechosenevent,and/ora``modifier'',whichmanipulatestheselectedwords.
Aneventspecificationcanbe
n
Anumber,referringtoaparticularevent
n
Anoffset,referringtotheeventnbeforethecurrentevent
#
Thecurrentevent.Thisshouldbeusedcarefullyincsh(1),wherethereisnocheckforrecursion.tcshallows10levelsofrecursion.(+)
!
Thepreviousevent(equivalentto`1')
s
Themostrecenteventwhosefirstwordbeginswiththestrings
?s?
Themostrecenteventwhichcontainsthestrings.Thesecond`?'canbeomittedifitisimmediatelyfollowedbyanewline.
Forexample,considerthisbitofsomeone'shistorylist:
98:30nroffmanwumpus.man
108:31cpwumpus.manwumpus.man.old
118:36viwumpus.man
128:37diffwumpus.man.oldwumpus.man
Thecommandsareshownwiththeireventnumbersandtimestamps.Thecurrentevent,whichwehaven'ttypedinyet,isevent13.`!11'and`!2'referto
event11.`!!'referstothepreviousevent,12.`!!'canbeabbreviated`!'ifitisfollowedby`:'(`:'isdescribedbelow).`!n'referstoevent9,whichbegins
with`n'.`!?old?'alsoreferstoevent12,whichcontains`old'.Withoutworddesignatorsormodifiershistoryreferencessimplyexpandtotheentireevent,so
wemighttype`!cp'toredothecopycommandor`!!|more'ifthe`diff'outputscrolledoffthetopofthescreen.
Historyreferencesmaybeinsulatedfromthesurroundingtextwithbracesifnecessary.Forexample,`!vdoc'wouldlookforacommandbeginningwith`vdoc',
and,inthisexample,notfindone,but`!{v}doc'wouldexpandunambiguouslyto`viwumpus.mandoc'.Eveninbraces,historysubstitutionsdonotnest.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

8/43

10/24/2015

cshLinuxCommandUnixCommand

(+)Whilecsh(1)expands,forexample,`!3d'toevent3withtheletter`d'appendedtoit,tcshexpandsittothelasteventbeginningwith`3d'only
completelynumericargumentsaretreatedaseventnumbers.Thismakesitpossibletorecalleventsbeginningwithnumbers.Toexpand`!3d'asincsh(1)say
`!\3d'.
Toselectwordsfromaneventwecanfollowtheeventspecificationbya`:'andadesignatorforthedesiredwords.Thewordsofaninputlinearenumbered
from0,thefirst(usuallycommand)wordbeing0,thesecondword(firstargument)being1,etc.Thebasicworddesignatorsare:
0
Thefirst(command)word
n
Thenthargument
^
Thefirstargument,equivalentto`1'
$
Thelastargument
%
Thewordmatchedbyan?s?search
xy
Arangeofwords
y
Equivalentto`0y'
*
Equivalentto`^$',butreturnsnothingiftheeventcontainsonly1word
x*
Equivalentto`x$'
x
Equivalentto`x*',butomittingthelastword(`$')
Selectedwordsareinsertedintothecommandlineseparatedbysingleblanks.Forexample,the`diff'commandinthepreviousexamplemighthavebeen
typedas`diff!!:1.old!!:1'(using`:1'toselectthefirstargumentfromthepreviousevent)or`diff!2:2!2:1'toselectandswaptheargumentsfromthe
`cp'command.Ifwedidn'tcareabouttheorderofthe`diff'wemighthavesaid`diff!2:12'orsimply`diff!2:*'.The`cp'commandmighthavebeen
written`cpwumpus.man!#:1.old',using`#'torefertothecurrentevent.`!n:hurkle.man'wouldreusethefirsttwowordsfromthe`nroff'commandto
say`nroffmanhurkle.man'.
The`:'separatingtheeventspecificationfromtheworddesignatorcanbeomittediftheargumentselectorbeginswitha`^',`$',`*',`%'or`'.For
example,our`diff'commandmighthavebeen`diff!!^.old!!^'or,equivalently,`diff!!$.old!!$'.However,if`!!'isabbreviated`!',anargumentselector
beginningwith`'willbeinterpretedasaneventspecification.
Ahistoryreferencemayhaveaworddesignatorbutnoeventspecification.Itthenreferencesthepreviouscommand.Continuingour`diff'example,wecould
havesaidsimply`diff!^.old!^'or,togettheargumentsintheoppositeorder,just`diff!*'.
Thewordorwordsinahistoryreferencecanbeedited,or``modified'',byfollowingitwithoneormoremodifiers,eachprecededbya`:':
h
Removeatrailingpathnamecomponent,leavingthehead.
t
Removeallleadingpathnamecomponents,leavingthetail.
r
Removeafilenameextension`.xxx',leavingtherootname.
e
Removeallbuttheextension.
u
Uppercasethefirstlowercaseletter.
l
Lowercasethefirstuppercaseletter.
s/l/r/
Substitutelforr.lissimplyastringliker,notaregularexpressionasintheeponymoused(1)command.Anycharactermaybeusedasthe

http://linux.about.com/library/cmd/blcmdl1_csh.htm

9/43

10/24/2015

cshLinuxCommandUnixCommand
delimiterinplaceof`/'a`\'canbeusedtoquotethedelimiterinsidelandr.Thecharacter`&'intherisreplacedbyl`\'alsoquotes`&'.Iflis
empty(``''),thelfromaprevioussubstitutionorthesfromaprevious`?s?'eventspecificationisused.Thetrailingdelimitermaybeomittedifit
isimmediatelyfollowedbyanewline.

&
Repeattheprevioussubstitution.
g
Applythefollowingmodifieroncetoeachword.
a(+)
Applythefollowingmodifierasmanytimesaspossibletoasingleword.`a'and`g'canbeusedtogethertoapplyamodifierglobally.Inthecurrent
implementation,usingthe`a'and`s'modifierstogethercanleadtoaninfiniteloop.Forexample,`:as/f/ff/'willneverterminate.Thisbehavior
mightchangeinthefuture.
p
Printthenewcommandlinebutdonotexecuteit.
q
Quotethesubstitutedwords,preventingfurthersubstitutions.
x
Likeq,butbreakintowordsatblanks,tabsandnewlines.
Modifiersareappliedtoonlythefirstmodifiableword(unless`g'isused).Itisanerrorfornowordtobemodifiable.
Forexample,the`diff'commandmighthavebeenwrittenas`diffwumpus.man.old!#^:r',using`:r'toremove`.old'fromthefirstargumentonthesame
line(`!#^').Wecouldsay`echohellooutthere',then`echo!*:u'tocapitalize`hello',`echo!*:au'tosayitoutloud,or`echo!*:agu'toreallyshout.We
mightfollow`mails"Iforgotmypassword"rot'with`!:s/rot/root'tocorrectthespellingof`root'(butseeSpellingcorrectionforadifferentapproach).
Thereisaspecialabbreviationforsubstitutions.`^',whenitisthefirstcharacteronaninputline,isequivalentto`!:s^'.Thuswemighthavesaid
`^rot^root'tomakethespellingcorrectioninthepreviousexample.Thisistheonlyhistorysubstitutionwhichdoesnotexplicitlybeginwith`!'.
(+)Incshassuch,onlyonemodifiermaybeappliedtoeachhistoryorvariableexpansion.Intcsh,morethanonemaybeused,forexample
%mvwumpus.man/usr/man/man1/wumpus.1
%man!$:t:r
manwumpus
Incsh,theresultwouldbe`wumpus.1:r'.Asubstitutionfollowedbyacolonmayneedtobeinsulatedfromitwithbraces:
>mva.out/usr/games/wumpus
>setenvPATH!$:h:$PATH
Bad!modifier:$.
>setenvPATH!{2$:h}:$PATH
setenvPATH/usr/games:/bin:/usr/bin:.
Thefirstattemptwouldsucceedincshbutfailsintcsh,becausetcshexpectsanothermodifierafterthesecondcolonratherthan`$'.
Finally,historycanbeaccessedthroughtheeditoraswellasthroughthesubstitutionsjustdescribed.Theupanddownhistory,historysearchbackwardand
forward,isearchbackandfwd,visearchbackandfwd,copyprevwordandinsertlastwordeditorcommandssearchforeventsinthehistorylistandcopy
themintotheinputbuffer.Thetoggleliteralhistoryeditorcommandswitchesbetweentheexpandedandliteralformsofhistorylinesintheinputbuffer.
expandhistoryandexpandlineexpandhistorysubstitutionsinthecurrentwordandintheentireinputbufferrespectively.
Aliassubstitution
Theshellmaintainsalistofaliaseswhichcanbeset,unsetandprintedbythealiasandunaliascommands.Afteracommandlineisparsedintosimple
commands(seeCommands)thefirstwordofeachcommand,lefttoright,ischeckedtoseeifithasanalias.Ifso,thefirstwordisreplacedbythealias.If
thealiascontainsahistoryreference,itundergoesHistorysubstitution(q.v.)asthoughtheoriginalcommandwerethepreviousinputline.Ifthealiasdoes
notcontainahistoryreference,theargumentlistisleftuntouched.
Thusifthealiasfor`ls'were`lsl'thecommand`ls/usr'wouldbecome`lsl/usr',theargumentlistherebeingundisturbed.Ifthealiasfor`lookup'were
`grep!^/etc/passwd'then`lookupbill'wouldbecome`grepbill/etc/passwd'.Aliasescanbeusedtointroduceparsermetasyntax.Forexample,`aliasprint'pr
\!*|lpr''definesa``command''(`print')whichpr(1)sitsargumentstothelineprinter.
Aliassubstitutionisrepeateduntilthefirstwordofthecommandhasnoalias.Ifanaliassubstitutiondoesnotchangethefirstword(asintheprevious
example)itisflaggedtopreventaloop.Otherloopsaredetectedandcauseanerror.
SomealiasesarereferredtobytheshellseeSpecialaliases.
Variablesubstitution

http://linux.about.com/library/cmd/blcmdl1_csh.htm

10/43

10/24/2015

cshLinuxCommandUnixCommand

Theshellmaintainsalistofvariables,eachofwhichhasasvaluealistofzeroormorewords.Thevaluesofshellvariablescanbedisplayedandchangedwith
thesetandunsetcommands.Thesystemmaintainsitsownlistof``environment''variables.Thesecanbedisplayedandchangedwithprintenv,setenvand
unsetenv.
(+)Variablesmaybemadereadonlywith`setr'(q.v.)Readonlyvariablesmaynotbemodifiedorunsetattemptingtodosowillcauseanerror.Oncemade
readonly,avariablecannotbemadewritable,so`setr'shouldbeusedwithcaution.Environmentvariablescannotbemadereadonly.
Somevariablesaresetbytheshellorreferredtobyit.Forinstance,theargvvariableisanimageoftheshell'sargumentlist,andwordsofthisvariable'svalue
arereferredtoinspecialways.Someofthevariablesreferredtobytheshellaretogglestheshelldoesnotcarewhattheirvalueis,onlywhethertheyareset
ornot.Forinstance,theverbosevariableisatogglewhichcausescommandinputtobeechoed.Thevcommandlineoptionsetsthisvariable.Specialshell
variableslistsallvariableswhicharereferredtobytheshell.
Otheroperationstreatvariablesnumerically.The`@'commandpermitsnumericcalculationstobeperformedandtheresultassignedtoavariable.Variable
valuesare,however,alwaysrepresentedas(zeroormore)strings.Forthepurposesofnumericoperations,thenullstringisconsideredtobezero,andthe
secondandsubsequentwordsofmultiwordvaluesareignored.
Aftertheinputlineisaliasedandparsed,andbeforeeachcommandisexecuted,variablesubstitutionisperformedkeyedby`$'characters.Thisexpansioncan
bepreventedbyprecedingthe`$'witha`\'exceptwithin`"'swhereitalwaysoccurs,andwithin`''swhereitneveroccurs.Stringsquotedby``'are
interpretedlater(seeCommandsubstitutionbelow)so`$'substitutiondoesnotoccurthereuntillater,ifatall.A`$'ispassedunchangediffollowedbya
blank,tab,orendofline.
Input/outputredirectionsarerecognizedbeforevariableexpansion,andarevariableexpandedseparately.Otherwise,thecommandnameandentireargument
listareexpandedtogether.Itisthuspossibleforthefirst(command)word(tothispoint)togeneratemorethanoneword,thefirstofwhichbecomesthe
commandname,andtherestofwhichbecomearguments.
Unlessenclosedin`"'orgiventhe`:q'modifiertheresultsofvariablesubstitutionmayeventuallybecommandandfilenamesubstituted.Within`"',a
variablewhosevalueconsistsofmultiplewordsexpandstoa(portionofa)singleword,withthewordsofthevariable'svalueseparatedbyblanks.Whenthe
`:q'modifierisappliedtoasubstitutionthevariablewillexpandtomultiplewordswitheachwordseparatedbyablankandquotedtopreventlatercommand
orfilenamesubstitution.
Thefollowingmetasequencesareprovidedforintroducingvariablevaluesintotheshellinput.Exceptasnoted,itisanerrortoreferenceavariablewhichisnot
set.
$name
${name}
Substitutesthewordsofthevalueofvariablename,eachseparatedbyablank.Bracesinsulatenamefromfollowingcharacterswhichwouldotherwise
bepartofit.Shellvariableshavenamesconsistingofupto20lettersanddigitsstartingwithaletter.Theunderscorecharacterisconsideredaletter.If
nameisnotashellvariable,butissetintheenvironment,thenthatvalueisreturned(but`:'modifiersandtheotherformsgivenbelowarenot
availableinthiscase).
$name[selector]
${name[selector]}
Substitutesonlytheselectedwordsfromthevalueofname.Theselectorissubjectedto`$'substitutionandmayconsistofasinglenumberortwo
numbersseparatedbya`'.Thefirstwordofavariable'svalueisnumbered`1'.Ifthefirstnumberofarangeisomitteditdefaultsto`1'.Ifthelast
memberofarangeisomitteditdefaultsto`$#name'.Theselector`*'selectsallwords.Itisnotanerrorforarangetobeemptyifthesecond
argumentisomittedorinrange.
$0
Substitutesthenameofthefilefromwhichcommandinputisbeingread.Anerroroccursifthenameisnotknown.
$number
${number}
Equivalentto`$argv[number]'.
$*
Equivalentto`$argv',whichisequivalentto`$argv[*]'.
The`:'modifiersdescribedunderHistorysubstitution,exceptfor`:p',canbeappliedtothesubstitutionsabove.Morethanonemaybeused.(+)Braces
maybeneededtoinsulateavariablesubstitutionfromaliteralcolonjustaswithHistorysubstitution(q.v.)anymodifiersmustappearwithinthebraces.
Thefollowingsubstitutionscannotbemodifiedwith`:'modifiers.
$?name
${?name}
Substitutesthestring`1'ifnameisset,`0'ifitisnot.
$?0
Substitutes`1'ifthecurrentinputfilenameisknown,`0'ifitisnot.Always`0'ininteractiveshells.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

11/43

10/24/2015

cshLinuxCommandUnixCommand

$#name
${#name}
Substitutesthenumberofwordsinname.
$#
Equivalentto`$#argv'.(+)
$%name
${%name}
Substitutesthenumberofcharactersinname.(+)
$%number
${%number}
Substitutesthenumberofcharactersin$argv[number].(+)
$?
Equivalentto`$status'.(+)
$$
Substitutesthe(decimal)processnumberofthe(parent)shell.
$!
Substitutesthe(decimal)processnumberofthelastbackgroundprocessstartedbythisshell.(+)
$_
Substitutesthecommandlineofthelastcommandexecuted.(+)
$<
Substitutesalinefromthestandardinput,withnofurtherinterpretationthereafter.Itcanbeusedtoreadfromthekeyboardinashellscript.(+)While
cshalwaysquotes$<,asifitwereequivalentto`$<:q',tcshdoesnot.Furthermore,whentcshiswaitingforalinetobetypedtheusermaytypean
interrupttointerruptthesequenceintowhichthelineistobesubstituted,butcshdoesnotallowthis.
Theeditorcommandexpandvariables,normallyboundto`^X$',canbeusedtointeractivelyexpandindividualvariables.
Command,filenameanddirectorystacksubstitution
Theremainingsubstitutionsareappliedselectivelytotheargumentsofbuiltincommands.Thismeansthatportionsofexpressionswhicharenotevaluatedare
notsubjectedtotheseexpansions.Forcommandswhicharenotinternaltotheshell,thecommandnameissubstitutedseparatelyfromtheargumentlist.
Thisoccursverylate,afterinputoutputredirectionisperformed,andinachildofthemainshell.
Commandsubstitution
Commandsubstitutionisindicatedbyacommandenclosedin``'.Theoutputfromsuchacommandisbrokenintoseparatewordsatblanks,tabsand
newlines,andnullwordsarediscarded.Theoutputisvariableandcommandsubstitutedandputinplaceoftheoriginalstring.
Commandsubstitutionsinsidedoublequotes(`"')retainblanksandtabsonlynewlinesforcenewwords.Thesinglefinalnewlinedoesnotforceanewwordin
anycase.Itisthuspossibleforacommandsubstitutiontoyieldonlypartofaword,evenifthecommandoutputsacompleteline.
Filenamesubstitution
Ifawordcontainsanyofthecharacters`*',`?',`['or`{'orbeginswiththecharacter`~'itisacandidateforfilenamesubstitution,alsoknownas
``globbing''.Thiswordisthenregardedasapattern(``globpattern''),andreplacedwithanalphabeticallysortedlistoffilenameswhichmatchthepattern.
Inmatchingfilenames,thecharacter`.'atthebeginningofafilenameorimmediatelyfollowinga`/',aswellasthecharacter`/'mustbematchedexplicitly.
Thecharacter`*'matchesanystringofcharacters,includingthenullstring.Thecharacter`?'matchesanysinglecharacter.Thesequence`[...]'matchesany
oneofthecharactersenclosed.Within`[...]',apairofcharactersseparatedby`'matchesanycharacterlexicallybetweenthetwo.
(+)Someglobpatternscanbenegated:Thesequence`[^...]'matchesanysinglecharacternotspecifiedbythecharactersand/orrangesofcharactersinthe
braces.
Anentireglobpatterncanalsobenegatedwith`^':
>echo*
bangcrashcrunchouch
>echo^cr*
bangouch
Globpatternswhichdonotuse`?',`*',or`[]'orwhichuse`{}'or`~'(below)arenotnegatedcorrectly.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

12/43

10/24/2015

cshLinuxCommandUnixCommand

Themetanotation`a{b,c,d}e'isashorthandfor`abeaceade'.Lefttorightorderispreserved:`/usr/source/s1/{oldls,ls}.c'expandsto`/usr/source/s1/oldls.c
/usr/source/s1/ls.c'.Theresultsofmatchesaresortedseparatelyatalowleveltopreservethisorder:`../{memo,*box}'mightexpandto`../memo../box
../mbox'.(Notethat`memo'wasnotsortedwiththeresultsofmatching`*box'.)Itisnotanerrorwhenthisconstructexpandstofileswhichdonotexist,but
itispossibletogetanerrorfromacommandtowhichtheexpandedlistispassed.Thisconstructmaybenested.Asaspecialcasethewords`{',`}'and`{}'
arepassedundisturbed.
Thecharacter`~'atthebeginningofafilenamereferstohomedirectories.Standingalone,i.e.,`~',itexpandstotheinvoker'shomedirectoryasreflectedin
thevalueofthehomeshellvariable.Whenfollowedbyanameconsistingofletters,digitsand`'characterstheshellsearchesforauserwiththatnameand
substitutestheirhomedirectorythus`~ken'mightexpandto`/usr/ken'and`~ken/chmach'to`/usr/ken/chmach'.Ifthecharacter`~'isfollowedbya
characterotherthanaletteror`/'orappearselsewherethanatthebeginningofaword,itisleftundisturbed.Acommandlike`setenvMANPATH
/usr/man:/usr/local/man:~/lib/man'doesnot,therefore,dohomedirectorysubstitutionasonemighthope.
Itisanerrorforaglobpatterncontaining`*',`?',`['or`~',withorwithout`^',nottomatchanyfiles.However,onlyonepatterninalistofglobpatterns
mustmatchafile(sothat,e.g.,`rm*.a*.c*.o'wouldfailonlyiftherewerenofilesinthecurrentdirectoryendingin`.a',`.c',or`.o'),andifthe
nonomatchshellvariableissetapattern(orlistofpatterns)whichmatchesnothingisleftunchangedratherthancausinganerror.
Thenoglobshellvariablecanbesettopreventfilenamesubstitution,andtheexpandglobeditorcommand,normallyboundto`^X*',canbeusedto
interactivelyexpandindividualfilenamesubstitutions.
Directorystacksubstitution(+)
Thedirectorystackisalistofdirectories,numberedfromzero,usedbythepushd,popdanddirsbuiltincommands(q.v.).dirscanprint,storeinafile,restore
andclearthedirectorystackatanytime,andthesavedirsanddirsfileshellvariablescanbesettostorethedirectorystackautomaticallyonlogoutand
restoreitonlogin.Thedirstackshellvariablecanbeexaminedtoseethedirectorystackandsettoputarbitrarydirectoriesintothedirectorystack.
Thecharacter`='followedbyoneormoredigitsexpandstoanentryinthedirectorystack.Thespecialcase`='expandstothelastdirectoryinthestack.For
example,
>dirsv
0/usr/bin
1/usr/spool/uucp
2/usr/accts/sys
>echo=1
/usr/spool/uucp
>echo=0/calendar
/usr/bin/calendar
>echo=
/usr/accts/sys
Thenoglobandnonomatchshellvariablesandtheexpandglobeditorcommandapplytodirectorystackaswellasfilenamesubstitutions.
Othersubstitutions(+)
Thereareseveralmoretransformationsinvolvingfilenames,notstrictlyrelatedtotheabovebutmentionedhereforcompleteness.Anyfilenamemaybe
expandedtoafullpathwhenthesymlinksvariable(q.v.)issetto`expand'.Quotingpreventsthisexpansion,andthenormalizepatheditorcommanddoesit
ondemand.ThenormalizecommandeditorcommandexpandscommandsinPATHintofullpathsondemand.Finally,cdandpushdinterpret`'astheold
workingdirectory(equivalenttotheshellvariableowd).Thisisnotasubstitutionatall,butanabbreviationrecognizedbyonlythosecommands.Nonetheless,
ittoocanbepreventedbyquoting.
Commands
Thenextthreesectionsdescribehowtheshellexecutescommandsanddealswiththeirinputandoutput.
Simplecommands,pipelinesandsequences
Asimplecommandisasequenceofwords,thefirstofwhichspecifiesthecommandtobeexecuted.Aseriesofsimplecommandsjoinedby`|'charactersforms
apipeline.Theoutputofeachcommandinapipelineisconnectedtotheinputofthenext.
Simplecommandsandpipelinesmaybejoinedintosequenceswith`',andwillbeexecutedsequentially.Commandsandpipelinescanalsobejoinedinto
sequenceswith`||'or`&&',indicating,asintheClanguage,thatthesecondistobeexecutedonlyifthefirstfailsorsucceedsrespectively.
Asimplecommand,pipelineorsequencemaybeplacedinparentheses,`()',toformasimplecommand,whichmayinturnbeacomponentofapipelineor
sequence.Acommand,pipelineorsequencecanbeexecutedwithoutwaitingforittoterminatebyfollowingitwithan`&'.
Builtinandnonbuiltincommandexecution
Builtincommandsareexecutedwithintheshell.Ifanycomponentofapipelineexceptthelastisabuiltincommand,thepipelineisexecutedinasubshell.
Parenthesizedcommandsarealwaysexecutedinasubshell.
(cdpwd)pwd

http://linux.about.com/library/cmd/blcmdl1_csh.htm

13/43

10/24/2015

cshLinuxCommandUnixCommand

thusprintsthehomedirectory,leavingyouwhereyouwere(printingthisafterthehomedirectory),while
cdpwd
leavesyouinthehomedirectory.Parenthesizedcommandsaremostoftenusedtopreventcdfromaffectingthecurrentshell.
Whenacommandtobeexecutedisfoundnottobeabuiltincommandtheshellattemptstoexecutethecommandviaexecve(2).Eachwordinthevariable
pathnamesadirectoryinwhichtheshellwilllookforthecommand.Ifitisgivenneitheracnoratoption,theshellhashesthenamesinthesedirectories
intoaninternaltablesothatitwilltryanexecve(2)inonlyadirectorywherethereisapossibilitythatthecommandresidesthere.Thisgreatlyspeeds
commandlocationwhenalargenumberofdirectoriesarepresentinthesearchpath.Ifthismechanismhasbeenturnedoff(viaunhash),iftheshellwas
givenacortargumentorinanycaseforeachdirectorycomponentofpathwhichdoesnotbeginwitha`/',theshellconcatenatesthecurrentworking
directorywiththegivencommandnametoformapathnameofafilewhichitthenattemptstoexecute.
Ifthefilehasexecutepermissionsbutisnotanexecutabletothesystem(i.e.,itisneitheranexecutablebinarynorascriptthatspecifiesitsinterpreter),then
itisassumedtobeafilecontainingshellcommandsandanewshellisspawnedtoreadit.Theshellspecialaliasmaybesettospecifyaninterpreterotherthan
theshellitself.
Onsystemswhichdonotunderstandthe`#!'scriptinterpreterconventiontheshellmaybecompiledtoemulateitseetheversionshellvariable.Ifso,the
shellchecksthefirstlineofthefiletoseeifitisoftheform`#!interpreterarg...'.Ifitis,theshellstartsinterpreterwiththegivenargsandfeedsthefiletoit
onstandardinput.
Input/output
Thestandardinputandstandardoutputofacommandmayberedirectedwiththefollowingsyntax:
<name
Openfilename(whichisfirstvariable,commandandfilenameexpanded)asthestandardinput.
<<word
Readtheshellinputuptoalinewhichisidenticaltoword.wordisnotsubjectedtovariable,filenameorcommandsubstitution,andeachinputlineis
comparedtowordbeforeanysubstitutionsaredoneonthisinputline.Unlessaquoting`\',`"',`'or``'appearsinwordvariableandcommand
substitutionisperformedontheinterveninglines,allowing`\'toquote`$',`\'and``'.Commandswhicharesubstitutedhaveallblanks,tabs,and
newlinespreserved,exceptforthefinalnewlinewhichisdropped.Theresultanttextisplacedinananonymoustemporaryfilewhichisgiventothe
commandasstandardinput.
>name
>!name
>&name
>&!name
Thefilenameisusedasstandardoutput.Ifthefiledoesnotexistthenitiscreatedifthefileexists,itistruncated,itspreviouscontentsbeinglost.
Iftheshellvariablenoclobberisset,thenthefilemustnotexistorbeacharacterspecialfile(e.g.,aterminalor`/dev/null')oranerrorresults.
Thishelpspreventaccidentaldestructionoffiles.Inthiscasethe`!'formscanbeusedtosuppressthischeck.
Theformsinvolving`&'routethediagnosticoutputintothespecifiedfileaswellasthestandardoutput.nameisexpandedinthesamewayas`<'
inputfilenamesare.
>>name
>>&name
>>!name
>>&!name
Like`>',butappendsoutputtotheendofname.Iftheshellvariablenoclobberisset,thenitisanerrorforthefilenottoexist,unlessoneofthe`!'
formsisgiven.
Acommandreceivestheenvironmentinwhichtheshellwasinvokedasmodifiedbytheinputoutputparametersandthepresenceofthecommandina
pipeline.Thus,unlikesomepreviousshells,commandsrunfromafileofshellcommandshavenoaccesstothetextofthecommandsbydefaultratherthey
receivetheoriginalstandardinputoftheshell.The`<<'mechanismshouldbeusedtopresentinlinedata.Thispermitsshellcommandscriptstofunctionas
componentsofpipelinesandallowstheshelltoblockreaditsinput.Notethatthedefaultstandardinputforacommandrundetachedisnottheemptyfile
/dev/null,buttheoriginalstandardinputoftheshell.Ifthisisaterminalandiftheprocessattemptstoreadfromtheterminal,thentheprocesswillblockand
theuserwillbenotified(seeJobs).
Diagnosticoutputmaybedirectedthroughapipewiththestandardoutput.Simplyusetheform`|&'ratherthanjust`|'.
Theshellcannotpresentlyredirectdiagnosticoutputwithoutalsoredirectingstandardoutput,but`(command>outputfile)>&errorfile'isoftenan
acceptableworkaround.Eitheroutputfileorerrorfilemaybe`/dev/tty'tosendoutputtotheterminal.
Features
Havingdescribedhowtheshellaccepts,parsesandexecutescommandlines,wenowturntoavarietyofitsusefulfeatures.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

14/43

10/24/2015

cshLinuxCommandUnixCommand

Controlflow
Theshellcontainsanumberofcommandswhichcanbeusedtoregulatetheflowofcontrolincommandfiles(shellscripts)and(inlimitedbutusefulways)
fromterminalinput.Thesecommandsalloperatebyforcingtheshelltorereadorskipinitsinputand,duetotheimplementation,restricttheplacementof
someofthecommands.
Theforeach,switch,andwhilestatements,aswellastheifthenelseformoftheifstatement,requirethatthemajorkeywordsappearinasinglesimple
commandonaninputlineasshownbelow.
Iftheshell'sinputisnotseekable,theshellbuffersupinputwheneveraloopisbeingreadandperformsseeksinthisinternalbuffertoaccomplishthe
rereadingimpliedbytheloop.(Totheextentthatthisallows,backwardgotoswillsucceedonnonseekableinputs.)
Expressions
Theif,whileandexitbuiltincommandsuseexpressionswithacommonsyntax.Theexpressionscanincludeanyoftheoperatorsdescribedinthenextthree
sections.Notethatthe@builtincommand(q.v.)hasitsownseparatesyntax.
Logical,arithmeticalandcomparisonoperators
TheseoperatorsaresimilartothoseofCandhavethesameprecedence.Theyinclude
||&&|^&==!==~!~<=>=
<><<>>+*/%!~()
Heretheprecedenceincreasestotheright,`=='`!='`=~'and`!~',`<='`>='`<'and`>',`<<'and`>>',`+'and`',`*'`/'and`%'being,ingroups,
atthesamelevel.The`=='`!='`=~'and`!~'operatorscomparetheirargumentsasstringsallothersoperateonnumbers.Theoperators`=~'and`!~'
arelike`!='and`=='exceptthattherighthandsideisaglobpattern(seeFilenamesubstitution)againstwhichthelefthandoperandismatched.This
reducestheneedforuseoftheswitchbuiltincommandinshellscriptswhenallthatisreallyneededispatternmatching.
Stringswhichbeginwith`0'areconsideredoctalnumbers.Nullormissingargumentsareconsidered`0'.Theresultsofallexpressionsarestrings,which
representdecimalnumbers.Itisimportanttonotethatnotwocomponentsofanexpressioncanappearinthesamewordexceptwhenadjacentto
componentsofexpressionswhicharesyntacticallysignificanttotheparser(`&'`|'`<'`>'`('`)')theyshouldbesurroundedbyspaces.
Commandexitstatus
Commandscanbeexecutedinexpressionsandtheirexitstatusreturnedbyenclosingtheminbraces(`{}').Rememberthatthebracesshouldbeseparated
fromthewordsofthecommandbyspaces.Commandexecutionssucceed,returningtrue,i.e.,`1',ifthecommandexitswithstatus0,otherwisetheyfail,
returningfalse,i.e.,`0'.Ifmoredetailedstatusinformationisrequiredthenthecommandshouldbeexecutedoutsideofanexpressionandthestatusshell
variableexamined.
Fileinquiryoperators
Someoftheseoperatorsperformtrue/falsetestsonfilesandrelatedobjects.Theyareoftheformopfile,whereopisoneof
r
Readaccess
w
Writeaccess
x
Executeaccess
X
Executableinthepathorshellbuiltin,e.g.,`Xls'and`XlsF'aregenerallytrue,but`X/bin/ls'isnot(+)
e
Existence
o
Ownership
z
Zerosize
s
Nonzerosize(+)
f
Plainfile
d

http://linux.about.com/library/cmd/blcmdl1_csh.htm

15/43

10/24/2015

cshLinuxCommandUnixCommand
Directory

l
Symboliclink(+)*
b
Blockspecialfile(+)
c
Characterspecialfile(+)
p
Namedpipe(fifo)(+)*
S
Socketspecialfile(+)*
u
SetuserIDbitisset(+)
g
SetgroupIDbitisset(+)
k
Stickybitisset(+)
t
file(whichmustbeadigit)isanopenfiledescriptorforaterminaldevice(+)
R
Hasbeenmigrated(convexonly)(+)
L
Appliessubsequentoperatorsinamultipleoperatortesttoasymboliclinkratherthantothefiletowhichthelinkpoints(+)*
fileiscommandandfilenameexpandedandthentestedtoseeifithasthespecifiedrelationshiptotherealuser.Iffiledoesnotexistorisinaccessibleor,for
theoperatorsindicatedby`*',ifthespecifiedfiletypedoesnotexistonthecurrentsystem,thenallenquiriesreturnfalse,i.e.,`0'.
Theseoperatorsmaybecombinedforconciseness:`xyfile'isequivalentto`xfile&&yfile'.(+)Forexample,`fx'istrue(returns`1')forplainexecutable
files,butnotfordirectories.
Lmaybeusedinamultipleoperatortesttoapplysubsequentoperatorstoasymboliclinkratherthantothefiletowhichthelinkpoints.Forexample,`lLo'is
trueforlinksownedbytheinvokinguser.Lr,LwandLxarealwaystrueforlinksandfalsefornonlinks.Lhasadifferentmeaningwhenitisthelastoperator
inamultipleoperatortestseebelow.
Itispossiblebutnotuseful,andsometimesmisleading,tocombineoperatorswhichexpectfiletobeafilewithoperatorswhichdonot,(e.g.,Xandt).
FollowingLwithanonfileoperatorcanleadtoparticularlystrangeresults.
Otheroperatorsreturnotherinformation,i.e.,notjust`0'or`1'.(+)Theyhavethesameformatasbeforeopmaybeoneof
A
Lastfileaccesstime,asthenumberofsecondssincetheepoch
A:
LikeA,butintimestampformat,e.g.,`FriMay1416:36:101993'
M
Lastfilemodificationtime
M:
LikeM,butintimestampformat
C
Lastinodemodificationtime
C:
LikeC,butintimestampformat
D
Devicenumber
I

http://linux.about.com/library/cmd/blcmdl1_csh.htm

16/43

10/24/2015

cshLinuxCommandUnixCommand
Inodenumber

F
Compositefileidentifier,intheformdevice:inode
L
Thenameofthefilepointedtobyasymboliclink
N
Numberof(hard)links
P
Permissions,inoctal,withoutleadingzero
P:
LikeP,withleadingzero
Pmode
Equivalentto`Pfile&mode',e.g.,`P22file'returns`22'iffileiswritablebygroupandother,`20'ifbygrouponly,and`0'ifbyneither
Pmode:
LikePmode:,withleadingzero
U
Numericuserid
U:
Username,orthenumericuseridiftheusernameisunknown
G
Numericgroupid
G:
Groupname,orthenumericgroupidifthegroupnameisunknown
Z
Size,inbytes
Onlyoneoftheseoperatorsmayappearinamultipleoperatortest,anditmustbethelast.NotethatLhasadifferentmeaningattheendofandelsewherein
amultipleoperatortest.Because`0'isavalidreturnvalueformanyoftheseoperators,theydonotreturn`0'whentheyfail:mostreturn`1',andFreturns
`:'.
IftheshelliscompiledwithPOSIXdefined(seetheversionshellvariable),theresultofafileinquiryisbasedonthepermissionbitsofthefileandnotonthe
resultoftheaccess(2)systemcall.Forexample,ifonetestsafilewithwwhosepermissionswouldordinarilyallowwritingbutwhichisonafilesystem
mountedreadonly,thetestwillsucceedinaPOSIXshellbutfailinanonPOSIXshell.
Fileinquiryoperatorscanalsobeevaluatedwiththefiletestbuiltincommand(q.v.)(+).
Jobs
Theshellassociatesajobwitheachpipeline.Itkeepsatableofcurrentjobs,printedbythejobscommand,andassignsthemsmallintegernumbers.Whena
jobisstartedasynchronouslywith`&',theshellprintsalinewhichlookslike
[1]1234
indicatingthatthejobwhichwasstartedasynchronouslywasjobnumber1andhadone(toplevel)process,whoseprocessidwas1234.
Ifyouarerunningajobandwishtodosomethingelseyoumayhitthesuspendkey(usually`^Z'),whichsendsaSTOPsignaltothecurrentjob.Theshellwill
thennormallyindicatethatthejobhasbeen`Suspended'andprintanotherprompt.Ifthelistjobsshellvariableisset,alljobswillbelistedlikethejobsbuiltin
commandifitissetto`long'thelistingwillbeinlongformat,like`jobsl'.Youcanthenmanipulatethestateofthesuspendedjob.Youcanputitinthe
``background''withthebgcommandorrunsomeothercommandsandeventuallybringthejobbackintothe``foreground''withfg.(Seealsotherunfg
editoreditorcommand.)A`^Z'takeseffectimmediatelyandislikeaninterruptinthatpendingoutputandunreadinputarediscardedwhenitistyped.The
waitbuiltincommandcausestheshelltowaitforallbackgroundjobstocomplete.
The`^]'keysendsadelayedsuspendsignal,whichdoesnotgenerateaSTOPsignaluntilaprogramattemptstoread(2)it,tothecurrentjob.Thiscan
usefullybetypedaheadwhenyouhavepreparedsomecommandsforajobwhichyouwishtostopafterithasreadthem.The`^Y'keyperformsthisfunction
incsh(1)intcsh,`^Y'isaneditingcommand.(+)
Ajobbeingruninthebackgroundstopsifittriestoreadfromtheterminal.Backgroundjobsarenormallyallowedtoproduceoutput,butthiscanbedisabled
bygivingthecommand`sttytostop'.Ifyousetthisttyoption,thenbackgroundjobswillstopwhentheytrytoproduceoutputliketheydowhentheytryto
readinput.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

17/43

10/24/2015

cshLinuxCommandUnixCommand

Thereareseveralwaystorefertojobsintheshell.Thecharacter`%'introducesajobname.Ifyouwishtorefertojobnumber1,youcannameitas`%1'.
Justnamingajobbringsittotheforegroundthus`%1'isasynonymfor`fg%1',bringingjob1backintotheforeground.Similarly,saying`%1&'resumes
job1inthebackground,justlike`bg%1'.Ajobcanalsobenamedbyanunambiguousprefixofthestringtypedintostartit:`%ex'wouldnormallyrestarta
suspendedex(1)job,iftherewereonlyonesuspendedjobwhosenamebeganwiththestring`ex'.Itisalsopossibletosay`%?string'tospecifyajobwhose
textcontainsstring,ifthereisonlyonesuchjob.
Theshellmaintainsanotionofthecurrentandpreviousjobs.Inoutputpertainingtojobs,thecurrentjobismarkedwitha`+'andthepreviousjobwitha`'.
Theabbreviations`%+',`%',and(byanalogywiththesyntaxofthehistorymechanism)`%%'allrefertothecurrentjob,and`%'referstotheprevious
job.
Thejobcontrolmechanismrequiresthatthestty(1)option`new'besetonsomesystems.Itisanartifactfroma`new'implementationofthettydriver
whichallowsgenerationofinterruptcharactersfromthekeyboardtotelljobstostop.Seestty(1)andthesettybuiltincommandfordetailsonsettingoptions
inthenewttydriver.
Statusreporting
Theshelllearnsimmediatelywheneveraprocesschangesstate.Itnormallyinformsyouwheneverajobbecomesblockedsothatnofurtherprogressis
possible,butonlyrightbeforeitprintsaprompt.Thisisdonesothatitdoesnototherwisedisturbyourwork.If,however,yousettheshellvariablenotify,the
shellwillnotifyyouimmediatelyofchangesofstatusinbackgroundjobs.Thereisalsoashellcommandnotifywhichmarksasingleprocesssothatitsstatus
changeswillbeimmediatelyreported.Bydefaultnotifymarksthecurrentprocesssimplysay`notify'afterstartingabackgroundjobtomarkit.
Whenyoutrytoleavetheshellwhilejobsarestopped,youwillbewarnedthat`Youhavestoppedjobs.'Youmayusethejobscommandtoseewhattheyare.
Ifyoudothisorimmediatelytrytoexitagain,theshellwillnotwarnyouasecondtime,andthesuspendedjobswillbeterminated.
Automatic,periodicandtimedevents(+)
Therearevariouswaystoruncommandsandtakeotheractionsautomaticallyatvarioustimesinthe``lifecycle''oftheshell.Theyaresummarizedhere,and
describedindetailundertheappropriateBuiltincommands,SpecialshellvariablesandSpecialaliases.
Theschedbuiltincommandputscommandsinascheduledeventlist,tobeexecutedbytheshellatagiventime.
Thebeepcmd,cwdcmd,periodic,precmd,postcmd,andjobcmdSpecialaliasescanbeset,respectively,toexecutecommandswhentheshellwantstoring
thebell,whentheworkingdirectorychanges,everytperiodminutes,beforeeachprompt,beforeeachcommandgetsexecuted,aftereachcommandgets
executed,andwhenajobisstartedorisbroughtintotheforeground.
Theautologoutshellvariablecanbesettologoutorlocktheshellafteragivennumberofminutesofinactivity.
Themailshellvariablecanbesettocheckfornewmailperiodically.
Theprintexitvalueshellvariablecanbesettoprinttheexitstatusofcommandswhichexitwithastatusotherthanzero.
Thermstarshellvariablecanbesettoasktheuser,when`rm*'istyped,ifthatisreallywhatwasmeant.
ThetimeshellvariablecanbesettoexecutethetimebuiltincommandafterthecompletionofanyprocessthattakesmorethanagivennumberofCPU
seconds.
Thewatchandwhoshellvariablescanbesettoreportwhenselectedusersloginorout,andthelogbuiltincommandreportsonthoseusersatanytime.
NativeLanguageSystemsupport(+)
Theshelliseightbitclean(ifsocompiledseetheversionshellvariable)andthussupportscharactersetsneedingthiscapability.NLSsupportdiffers
dependingonwhetherornottheshellwascompiledtousethesystem'sNLS(again,seeversion).Ineithercase,7bitASCIIisthedefaultforcharacter
classification(e.g.,whichcharactersareprintable)andsorting,andchangingtheLANGorLC_CTYPEenvironmentvariablescausesacheckforpossible
changesintheserespects.
Whenusingthesystem'sNLS,thesetlocale(3)functioniscalledtodetermineappropriatecharacterclassificationandsorting.Thisfunctiontypicallyexamines
theLANGandLC_CTYPEenvironmentvariablesrefertothesystemdocumentationforfurtherdetails.Whennotusingthesystem'sNLS,theshellsimulates
itbyassumingthattheISO88591charactersetisusedwhenevereitheroftheLANGandLC_CTYPEvariablesareset,regardlessoftheirvalues.Sortingis
notaffectedforthesimulatedNLS.
Inaddition,withbothrealandsimulatedNLS,allprintablecharactersintherange\200\377,i.e.,thosethathaveMcharbindings,areautomaticallyrebound
toselfinsertcommand.Thecorrespondingbindingfortheescapecharsequence,ifany,isleftalone.ThesecharactersarenotreboundiftheNOREBIND
environmentvariableisset.ThismaybeusefulforthesimulatedNLSoraprimitiverealNLSwhichassumesfullISO88591.Otherwise,allMcharbindingsin
therange\240\377areeffectivelyundone.Explicitlyrebindingtherelevantkeyswithbindkeyisofcoursestillpossible.
Unknowncharacters(i.e.,thosethatareneitherprintablenorcontrolcharacters)areprintedintheformat\nnn.Ifthettyisnotin8bitmode,other8bit
charactersareprintedbyconvertingthemtoASCIIandusingstandoutmode.Theshellneverchangesthe7/8bitmodeofthettyandtracksuserinitiated
changesof7/8bitmode.NLSusers(or,forthatmatter,thosewhowanttouseametakey)mayneedtoexplicitlysetthettyin8bitmodethroughthe
appropriatestty(1)commandin,e.g.,the~/.loginfile.
OSvariantsupport(+)

http://linux.about.com/library/cmd/blcmdl1_csh.htm

18/43

10/24/2015

cshLinuxCommandUnixCommand

Anumberofnewbuiltincommandsareprovidedtosupportfeaturesinparticularoperatingsystems.AllaredescribedindetailintheBuiltincommands
section.
OnsystemsthatsupportTCF(aixibm370,aixps2),getspathandsetspathgetandsetthesystemexecutionpath,getxversandsetxversgetandsetthe
experimentalversionprefixandmigratemigratesprocessesbetweensites.Thejobsbuiltinprintsthesiteonwhicheachjobisexecuting.
UnderDomain/OS,inlibaddssharedlibrariestothecurrentenvironment,rootnodechangestherootnodeandverchangesthesystype.
UnderMach,setpathisequivalenttoMach'ssetpath(1).
UnderMasscomp/RTUandHarrisCX/UX,universesetstheuniverse.
UnderHarrisCX/UX,ucborattrunsacommandunderthespecifieduniverse.
UnderConvex/OS,warpprintsorsetstheuniverse.
TheVENDOR,OSTYPEandMACHTYPEenvironmentvariablesindicaterespectivelythevendor,operatingsystemandmachinetype(microprocessorclassor
machinemodel)ofthesystemonwhichtheshellthinksitisrunning.Theseareparticularlyusefulwhensharingone'shomedirectorybetweenseveraltypesof
machinesonecan,forexample,
setpath=(~/bin.$MACHTYPE/usr/ucb/bin/usr/bin.)
inone's~/.loginandputexecutablescompiledforeachmachineintheappropriatedirectory.
Theversionshellvariableindicateswhatoptionswerechosenwhentheshellwascompiled.
Notealsothenewgrpbuiltin,theafsuserandecho_styleshellvariablesandthesystemdependentlocationsoftheshell'sinputfiles(seeFILES).
Signalhandling
Loginshellsignoreinterruptswhenreadingthefile~/.logout.Theshellignoresquitsignalsunlessstartedwithq.Loginshellscatchtheterminatesignal,but
nonloginshellsinherittheterminatebehaviorfromtheirparents.Othersignalshavethevalueswhichtheshellinheritedfromitsparent.
Inshellscripts,theshell'shandlingofinterruptandterminatesignalscanbecontrolledwithonintr,anditshandlingofhangupscanbecontrolledwithhupand
nohup.
Theshellexitsonahangup(seealsothelogoutshellvariable).Bydefault,theshell'schildrendotoo,buttheshelldoesnotsendthemahangupwhenit
exits.huparrangesfortheshelltosendahanguptoachildwhenitexits,andnohupsetsachildtoignorehangups.
Terminalmanagement(+)
Theshellusesthreedifferentsetsofterminal(``tty'')modes:`edit',usedwhenediting,`quote',usedwhenquotingliteralcharacters,and`execute',used
whenexecutingcommands.Theshellholdssomesettingsineachmodeconstant,socommandswhichleavethettyinaconfusedstatedonotinterferewith
theshell.Theshellalsomatcheschangesinthespeedandpaddingofthetty.Thelistofttymodesthatarekeptconstantcanbeexaminedandmodifiedwith
thesettybuiltin.NotethatalthoughtheeditorusesCBREAKmode(oritsequivalent),ittakestypedaheadcharactersanyway.
Theechotc,settcandtelltccommandscanbeusedtomanipulateanddebugterminalcapabilitiesfromthecommandline.
OnsystemsthatsupportSIGWINCHorSIGWINDOW,theshelladaptstowindowresizingautomaticallyandadjuststheenvironmentvariablesLINESand
COLUMNSifset.IftheenvironmentvariableTERMCAPcontainsli#andco#fields,theshelladjuststhemtoreflectthenewwindowsize.
REFERENCE
ThenextsectionsofthismanualdescribealloftheavailableBuiltincommands,SpecialaliasesandSpecialshellvariables.
Builtincommands
%job
Asynonymforthefgbuiltincommand.
%job&
Asynonymforthebgbuiltincommand.
:
Doesnothing,successfully.
@
@name=expr
@name[index]=expr
@name++|
@name[index]++|

http://linux.about.com/library/cmd/blcmdl1_csh.htm

19/43

10/24/2015

cshLinuxCommandUnixCommand

Thefirstformprintsthevaluesofallshellvariables.
Thesecondformassignsthevalueofexprtoname.Thethirdformassignsthevalueofexprtotheindex'thcomponentofnamebothnameand
itsindex'thcomponentmustalreadyexist.
exprmaycontaintheoperators`*',`+',etc.,asinC.Ifexprcontains`<',`>',`&'or`'thenatleastthatpartofexprmustbeplacedwithin`()'.
NotethatthesyntaxofexprhasnothingtodowiththatdescribedunderExpressions.
Thefourthandfifthformsincrement(`++')ordecrement(`')nameoritsindex'thcomponent.
Thespacebetween`@'andnameisrequired.Thespacesbetweennameand`='andbetween`='andexprareoptional.Componentsofexpr
mustbeseparatedbyspaces.
alias[name[wordlist]]
Withoutarguments,printsallaliases.Withname,printsthealiasforname.Withnameandwordlist,assignswordlistasthealiasofname.wordlistis
commandandfilenamesubstituted.namemaynotbe`alias'or`unalias'.Seealsotheunaliasbuiltincommand.
alloc
Showstheamountofdynamicmemoryacquired,brokendownintousedandfreememory.Withanargumentshowsthenumberoffreeandusedblocks
ineachsizecategory.Thecategoriesstartatsize8anddoubleateachstep.Thiscommand'soutputmayvaryacrosssystemtypes,becausesystems
otherthantheVAXmayuseadifferentmemoryallocator.
bg[%job...]
Putsthespecifiedjobs(or,withoutarguments,thecurrentjob)intothebackground,continuingeachifitisstopped.jobmaybeanumber,astring,`',
`%',`+'or`'asdescribedunderJobs.
bindkey[l|d|e|v|u](+)
bindkey[a][b][k][r][]key(+)
bindkey[a][b][k][c|s][]keycommand(+)
Withoutoptions,thefirstformlistsallboundkeysandtheeditorcommandtowhicheachisbound,thesecondformliststheeditorcommandtowhich
keyisboundandthethirdformbindstheeditorcommandcommandtokey.Optionsinclude:
l
Listsalleditorcommandsandashortdescriptionofeach.
d
Bindsallkeystothestandardbindingsforthedefaulteditor.
e
BindsallkeystothestandardGNUEmacslikebindings.
v
Bindsallkeystothestandardvi(1)likebindings.
a
Listsorchangeskeybindingsinthealternativekeymap.Thisisthekeymapusedinvicommandmode.
b
keyisinterpretedasacontrolcharacterwritten^character(e.g.,`^A')orCcharacter(e.g.,`CA'),ametacharacterwrittenMcharacter(e.g.,
`MA'),afunctionkeywrittenFstring(e.g.,`Fstring'),oranextendedprefixkeywrittenXcharacter(e.g.,`XA').
k
keyisinterpretedasasymbolicarrowkeyname,whichmaybeoneof`down',`up',`left'or`right'.
r
Removeskey'sbinding.Becareful:`bindkeyr'doesnotbindkeytoselfinsertcommand(q.v.),itunbindskeycompletely.
c
commandisinterpretedasabuiltinorexternalcommandinsteadofaneditorcommand.
s
commandistakenasaliteralstringandtreatedasterminalinputwhenkeyistyped.Boundkeysincommandarethemselvesreinterpreted,and
thiscontinuesfortenlevelsofinterpretation.

Forcesabreakfromoptionprocessing,sothenextwordistakenaskeyevenifitbeginswith''.
u(oranyinvalidoption)
Printsausagemessage.
keymaybeasinglecharacterorastring.Ifacommandisboundtoastring,thefirstcharacterofthestringisboundtosequenceleadinandtheentire

http://linux.about.com/library/cmd/blcmdl1_csh.htm

20/43

10/24/2015

cshLinuxCommandUnixCommand

stringisboundtothecommand.
Controlcharactersinkeycanbeliteral(theycanbetypedbyprecedingthemwiththeeditorcommandquotedinsert,normallyboundto`^V')orwritten
caretcharacterstyle,e.g.,`^A'.Deleteiswritten`^?'(caretquestionmark).keyandcommandcancontainbackslashedescapesequences(inthestyle
ofSystemVecho(1))asfollows:
\aBell
\b
Backspace
\e
Escape
\f
Formfeed
\n
Newline
\r
Carriagereturn
\t
Horizontaltab
\v
Verticaltab
\nnn
TheASCIIcharactercorrespondingtotheoctalnumbernnn
`\'nullifiesthespecialmeaningofthefollowingcharacter,ifithasany,notably`\'and`^'.
break
Causesexecutiontoresumeaftertheendofthenearestenclosingforeachorwhile.Theremainingcommandsonthecurrentlineareexecuted.Multi
levelbreaksarethuspossiblebywritingthemallononeline.
breaksw
Causesabreakfromaswitch,resumingaftertheendsw.
builtins(+)
Printsthenamesofallbuiltincommands.
bye(+)
Asynonymforthelogoutbuiltincommand.Availableonlyiftheshellwassocompiledseetheversionshellvariable.
caselabel:
Alabelinaswitchstatementasdiscussedbelow.
cd[p][l][n|v][name]
Ifadirectorynameisgiven,changestheshell'sworkingdirectorytoname.Ifnot,changestohome.Ifnameis`'itisinterpretedastheprevious
workingdirectory(seeOthersubstitutions).(+)Ifnameisnotasubdirectoryofthecurrentdirectory(anddoesnotbeginwith`/',`./'or`../'),each
componentofthevariablecdpathischeckedtoseeifithasasubdirectoryname.Finally,ifallelsefailsbutnameisashellvariablewhosevaluebegins
with`/',thenthisistriedtoseeifitisadirectory.
Withp,printsthefinaldirectorystack,justlikedirs.Thel,nandvflagshavethesameeffectoncdasondirs,andtheyimplyp.(+)
Seealsotheimplicitcdshellvariable.
chdir
Asynonymforthecdbuiltincommand.
complete[command[word/pattern/list[:select]/[[suffix]/]...]](+)
Withoutarguments,listsallcompletions.Withcommand,listscompletionsforcommand.Withcommandandwordetc.,definescompletions.
commandmaybeafullcommandnameoraglobpattern(seeFilenamesubstitution).Itcanbeginwith`'toindicatethatcompletionshould
beusedonlywhencommandisambiguous.
wordspecifieswhichwordrelativetothecurrentwordistobecompleted,andmaybeoneofthefollowing:
c

http://linux.about.com/library/cmd/blcmdl1_csh.htm

21/43

10/24/2015

cshLinuxCommandUnixCommand
Currentwordcompletion.patternisaglobpatternwhichmustmatchthebeginningofthecurrentwordonthecommandline.pattern
isignoredwhencompletingthecurrentword.
C
Likec,butincludespatternwhencompletingthecurrentword.
n
Nextwordcompletion.patternisaglobpatternwhichmustmatchthebeginningofthepreviouswordonthecommandline.
N
Liken,butmustmatchthebeginningofthewordtwobeforethecurrentword.
p
Positiondependentcompletion.patternisanumericrange,withthesamesyntaxusedtoindexshellvariables,whichmustincludethe
currentword.
list,thelistofpossiblecompletions,maybeoneofthefollowing:
a
Aliases
b
Bindings(editorcommands)
c
Commands(builtinorexternalcommands)
C
Externalcommandswhichbeginwiththesuppliedpathprefix
d
Directories
D
Directorieswhichbeginwiththesuppliedpathprefix
e
Environmentvariables
f
Filenames
F
Filenameswhichbeginwiththesuppliedpathprefix
g
Groupnames
j
Jobs
l
Limits
n
Nothing
s
Shellvariables
S
Signals
t
Plain(``text'')files
T
Plain(``text'')fileswhichbeginwiththesuppliedpathprefix
v
Anyvariables

http://linux.about.com/library/cmd/blcmdl1_csh.htm

22/43

10/24/2015

cshLinuxCommandUnixCommand
u
Usernames
x
Liken,butprintsselectwhenlistchoicesisused.
X
Completions
$var
Wordsfromthevariablevar
(...)
Wordsfromthegivenlist
`...`
Wordsfromtheoutputofcommand
selectisanoptionalglobpattern.Ifgiven,wordsfromonlylistthatmatchselectareconsideredandthefignoreshellvariableisignored.Thelast
threetypesofcompletionmaynothaveaselectpattern,andxusesselectasanexplanatorymessagewhenthelistchoiceseditorcommandis
used.
suffixisasinglecharactertobeappendedtoasuccessfulcompletion.Ifnull,nocharacterisappended.Ifomitted(inwhichcasethefourth
delimitercanalsobeomitted),aslashisappendedtodirectoriesandaspacetootherwords.
Nowforsomeexamples.Somecommandstakeonlydirectoriesasarguments,sothere'snopointcompletingplainfiles.
>completecd'p/1/d/'
completesonlythefirstwordfollowing`cd'(`p/1')withadirectory.ptypecompletioncanalsobeusedtonarrowdowncommandcompletion:
>co[^D]
completecompress
>completeco*'p/0/(compress)/'
>co[^D]
>compress
Thiscompletioncompletescommands(wordsinposition0,`p/0')whichbeginwith`co'(thusmatching`co*')to`compress'(theonlywordinthe
list).Theleading`'indicatesthatthiscompletionistobeusedwithonlyambiguouscommands.
>completefind'n/user/u/'
isanexampleofntypecompletion.Anywordfollowing`find'andimmediatelyfollowing`user'iscompletedfromthelistofusers.
>completecc'c/I/d/'
demonstratesctypecompletion.Anywordfollowing`cc'andbeginningwith`I'iscompletedasadirectory.`I'isnottakenaspartofthe
directorybecauseweusedlowercasec.
Differentlistsareusefulwithdifferentcommands.
>completealias'p/1/a/'
>completeman'p/*/c/'
>completeset'p/1/s/'
>completetrue'p/1/x:Truthhasnooptions./'
Thesecompletewordsfollowing`alias'withaliases,`man'withcommands,and`set'withshellvariables.`true'doesn'thaveanyoptions,sox
doesnothingwhencompletionisattemptedandprints`Truthhasnooptions.'whencompletionchoicesarelisted.
Notethatthemanexample,andseveralotherexamplesbelow,couldjustaswellhaveused'c/*'or'n/*'as'p/*'.
Wordscanbecompletedfromavariableevaluatedatcompletiontime,
>completeftp'p/1/$hostnames/'
>sethostnames=(rtfm.mit.edutesla.ee.cornell.edu)
>ftp[^D]
rtfm.mit.edutesla.ee.cornell.edu
>ftp[^C]
>sethostnames=(rtfm.mit.edutesla.ee.cornell.eduuunet.uu.net)
>ftp[^D]
rtfm.mit.edutesla.ee.cornell.eduuunet.uu.net

http://linux.about.com/library/cmd/blcmdl1_csh.htm

23/43

10/24/2015

cshLinuxCommandUnixCommand
orfromacommandrunatcompletiontime:
>completekill'p/*/`ps|awk\{print\\$1\}`/'
>kill9[^D]
23113233772338023406234292352923530PID
Notethatthecompletecommanddoesnotitselfquoteitsarguments,sothebraces,spaceand`$'in`{print$1}'mustbequotedexplicitly.
Onecommandcanhavemultiplecompletions:
>completedbx'p/2/(core)/''p/*/c/'
completesthesecondargumentto`dbx'withtheword`core'andallotherargumentswithcommands.Notethatthepositionalcompletionis
specifiedbeforethenextwordcompletion.Becausecompletionsareevaluatedfromlefttoright,ifthenextwordcompletionwerespecifiedfirstit
wouldalwaysmatchandthepositionalcompletionwouldneverbeexecuted.Thisisacommonmistakewhendefiningacompletion.
Theselectpatternisusefulwhenacommandtakesfileswithonlyparticularformsasarguments.Forexample,
>completecc'p/*/f:*.[cao]/'
completes`cc'argumentstofilesendinginonly`.c',`.a',or`.o'.selectcanalsoexcludefiles,usingnegationofaglobpatternasdescribedunder
Filenamesubstitution.Onemightuse
>completerm'p/*/f:^*.{c,h,cc,C,tex,1,man,l,y}/'
toexcludeprecioussourcecodefrom`rm'completion.Ofcourse,onecouldstilltypeexcludednamesmanuallyoroverridethecompletion
mechanismusingthecompletewordraworlistchoicesraweditorcommands(q.v.).
The`C',`D',`F'and`T'listsarelike`c',`d',`f'and`t'respectively,buttheyusetheselectargumentinadifferentway:torestrictcompletionto
filesbeginningwithaparticularpathprefix.Forexample,theElmmailprogramuses`='asanabbreviationforone'smaildirectory.Onemightuse
>completeelmc@=@F:$HOME/Mail/@
tocomplete`elmf='asifitwere`elmf~/Mail/'.Notethatweused`@'insteadof`/'toavoidconfusionwiththeselectargument,andweused
`$HOME'insteadof`~'becausehomedirectorysubstitutionworksatonlythebeginningofaword.
suffixisusedtoaddanonstandardsuffix(notspaceor`/'fordirectories)tocompletedwords.
>completefinger'c/*@/$hostnames/''p/1/u/@'
completesargumentsto`finger'fromthelistofusers,appendsan`@',andthencompletesafterthe`@'fromthe`hostnames'variable.Note
againtheorderinwhichthecompletionsarespecified.
Finally,here'sacomplexexampleforinspiration:
>completefind\
'n/name/f/''n/newer/f/''n/{,n}cpio/f/'\
'n/exec/c/''n/ok/c/''n/user/u/'\
'n/group/g/''n/fstype/(nfs4.2)/'\
'n/type/(bcdflps)/'\
'c//(namenewercpioncpioexecokuser\
groupfstypetypeatimectimedepthinum\
lsmtimenogroupnouserpermprintprune\
sizexdev)/'\
'p/*/d/'
Thiscompleteswordsfollowing`name',`newer',`cpio'or`ncpio'(notethepatternwhichmatchesboth)tofiles,wordsfollowing`exec'or`
ok'tocommands,wordsfollowing`user'and`group'tousersandgroupsrespectivelyandwordsfollowing`fstype'or`type'tomembersofthe
givenlists.Italsocompletestheswitchesthemselvesfromthegivenlist(notetheuseofctypecompletion)andcompletesanythingnototherwise
completedtoadirectory.Whew.
Rememberthatprogrammedcompletionsareignoredifthewordbeingcompletedisatildesubstitution(beginningwith`~')oravariable
(beginningwith`$').completeisanexperimentalfeature,andthesyntaxmaychangeinfutureversionsoftheshell.Seealsotheuncomplete
builtincommand.

continue
Continuesexecutionofthenearestenclosingwhileorforeach.Therestofthecommandsonthecurrentlineareexecuted.
default:
Labelsthedefaultcaseinaswitchstatement.Itshouldcomeafterallcaselabels.
dirs[l][n|v]

http://linux.about.com/library/cmd/blcmdl1_csh.htm

24/43

10/24/2015

cshLinuxCommandUnixCommand

dirsS|L[filename](+)
dirsc(+)
Thefirstformprintsthedirectorystack.Thetopofthestackisattheleftandthefirstdirectoryinthestackisthecurrentdirectory.Withl,`~'or
`~name'intheoutputisexpandedexplicitlytohomeorthepathnameofthehomedirectoryforusername.(+)Withn,entriesarewrappedbefore
theyreachtheedgeofthescreen.(+)Withv,entriesareprintedoneperline,precededbytheirstackpositions.(+)Ifmorethanoneofnorvis
given,vtakesprecedence.pisacceptedbutdoesnothing.
WithS,thesecondformsavesthedirectorystacktofilenameasaseriesofcdandpushdcommands.WithL,theshellsourcesfilename,whichis
presumablyadirectorystackfilesavedbytheSoptionorthesavedirsmechanism.Ineithercase,dirsfileisusediffilenameisnotgivenand
~/.cshdirsisusedifdirsfileisunset.
Notethatloginshellsdotheequivalentof`dirsL'onstartupand,ifsavedirsisset,`dirsS'beforeexiting.Becauseonly~/.tcshrcisnormally
sourcedbefore~/.cshdirs,dirsfileshouldbesetin~/.tcshrcratherthan~/.login.
Thelastformclearsthedirectorystack.
echo[n]word...
Writeseachwordtotheshell'sstandardoutput,separatedbyspacesandterminatedwithanewline.Theecho_styleshellvariablemaybesetto
emulate(ornot)theflagsandescapesequencesoftheBSDand/orSystemVversionsofechoseeecho(1).
echotc[sv]arg...(+)
Exercisestheterminalcapabilities(seetermcap(5))inargs.Forexample,'echotchome'sendsthecursortothehomeposition,'echotccm310'sendsit
tocolumn3androw10,and'echotcts0echo"Thisisatest."echotcfs'prints"Thisisatest."inthestatusline.
Ifargis'baud','cols','lines','meta'or'tabs',printsthevalueofthatcapability("yes"or"no"indicatingthattheterminaldoesordoesnothavethat
capability).Onemightusethistomaketheoutputfromashellscriptlessverboseonslowterminals,orlimitcommandoutputtothenumberof
linesonthescreen:
>sethistory=`echotclines`
>@history
Termcapstringsmaycontainwildcardswhichwillnotechocorrectly.Oneshouldusedoublequoteswhensettingashellvariabletoaterminal
capabilitystring,asinthefollowingexamplethatplacesthedateinthestatusline:
>settosl="`echotcts0`"
>setfrsl="`echotcfs`"
>echon"$tosl"dateechon"$frsl"
Withs,nonexistentcapabilitiesreturntheemptystringratherthancausinganerror.Withv,messagesareverbose.
else
end
endif
endsw
Seethedescriptionoftheforeach,if,switch,andwhilestatementsbelow.
evalarg...
Treatstheargumentsasinputtotheshellandexecutestheresultingcommand(s)inthecontextofthecurrentshell.Thisisusuallyusedtoexecute
commandsgeneratedastheresultofcommandorvariablesubstitution,becauseparsingoccursbeforethesesubstitutions.Seetset(1)forasampleuse
ofeval.
execcommand
Executesthespecifiedcommandinplaceofthecurrentshell.
exit[expr]
Theshellexitseitherwiththevalueofthespecifiedexpr(anexpression,asdescribedunderExpressions)or,withoutexpr,withthevalueofthestatus
variable.
fg[%job...]
Bringsthespecifiedjobs(or,withoutarguments,thecurrentjob)intotheforeground,continuingeachifitisstopped.jobmaybeanumber,astring,`',
`%',`+'or`'asdescribedunderJobs.Seealsotherunfgeditoreditorcommand.
filetestopfile...(+)
Appliesop(whichisafileinquiryoperatorasdescribedunderFileinquiryoperators)toeachfileandreturnstheresultsasaspaceseparatedlist.
foreachname(wordlist)
...
end
Successivelysetsthevariablenametoeachmemberofwordlistandexecutesthesequenceofcommandsbetweenthiscommandandthematchingend.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

25/43

10/24/2015

cshLinuxCommandUnixCommand

(Bothforeachandendmustappearaloneonseparatelines.)Thebuiltincommandcontinuemaybeusedtocontinuetheloopprematurelyandthe
builtincommandbreaktoterminateitprematurely.Whenthiscommandisreadfromtheterminal,theloopisreadoncepromptingwith`foreach?'(or
prompt2)beforeanystatementsintheloopareexecuted.Ifyoumakeamistaketypinginaloopattheterminalyoucanrubitout.
getspath(+)
Printsthesystemexecutionpath.(TCFonly)
getxvers(+)
Printstheexperimentalversionprefix.(TCFonly)
globwordlist
Likeecho,butno`\'escapesarerecognizedandwordsaredelimitedbynullcharactersintheoutput.Usefulforprogramswhichwishtousetheshellto
filenameexpandalistofwords.
gotoword
wordisfilenameandcommandsubstitutedtoyieldastringoftheform`label'.Theshellrewindsitsinputasmuchaspossible,searchesforalineofthe
form`label:',possiblyprecededbyblanksortabs,andcontinuesexecutionafterthatline.
hashstat
Printsastatisticslineindicatinghoweffectivetheinternalhashtablehasbeenatlocatingcommands(andavoidingexec's).Anexecisattemptedforeach
componentofthepathwherethehashfunctionindicatesapossiblehit,andineachcomponentwhichdoesnotbeginwitha`/'.
Onmachineswithoutvfork(2),printsonlythenumberandsizeofhashbuckets.
history[hTr][n]
historyS|L|M[filename](+)
historyc(+)
Thefirstformprintsthehistoryeventlist.Ifnisgivenonlythenmostrecenteventsareprintedorsaved.Withh,thehistorylistisprintedwithout
leadingnumbers.IfTisspecified,timestampsareprintedalsoincommentform.(Thiscanbeusedtoproducefilessuitableforloadingwith'historyL'or
'sourceh'.)Withr,theorderofprintingismostrecentfirstratherthanoldestfirst.
WithS,thesecondformsavesthehistorylisttofilename.Ifthefirstwordofthesavehistshellvariableissettoanumber,atmostthatmany
linesaresaved.Ifthesecondwordofsavehistissetto`merge',thehistorylistismergedwiththeexistinghistoryfileinsteadofreplacingit(if
thereisone)andsortedbytimestamp.(+)MergingisintendedforanenvironmentliketheXWindowSystemwithseveralshellsinsimultaneous
use.Currentlyitsucceedsonlywhentheshellsquitnicelyoneafteranother.
WithL,theshellappendsfilename,whichispresumablyahistorylistsavedbytheSoptionorthesavehistmechanism,tothehistorylist.Mis
likeL,butthecontentsoffilenamearemergedintothehistorylistandsortedbytimestamp.Ineithercase,histfileisusediffilenameisnot
givenand~/.historyisusedifhistfileisunset.`historyL'isexactlylike'sourceh'exceptthatitdoesnotrequireafilename.
Notethatloginshellsdotheequivalentof`historyL'onstartupand,ifsavehistisset,`historyS'beforeexiting.Becauseonly~/.tcshrcis
normallysourcedbefore~/.history,histfileshouldbesetin~/.tcshrcratherthan~/.login.
Ifhistlitisset,thefirstandsecondformsprintandsavetheliteral(unexpanded)formofthehistorylist.
Thelastformclearsthehistorylist.
hup[command](+)
Withcommand,runscommandsuchthatitwillexitonahangupsignalandarrangesfortheshelltosenditahangupsignalwhentheshellexits.Note
thatcommandsmaysettheirownresponsetohangups,overridinghup.Withoutanargument(allowedinonlyashellscript),causestheshelltoexiton
ahangupfortheremainderofthescript.SeealsoSignalhandlingandthenohupbuiltincommand.
if(expr)command
Ifexpr(anexpression,asdescribedunderExpressions)evaluatestrue,thencommandisexecuted.Variablesubstitutiononcommandhappensearly,at
thesametimeitdoesfortherestoftheifcommand.commandmustbeasimplecommand,notanalias,apipeline,acommandlistoraparenthesized
commandlist,butitmayhavearguments.Input/outputredirectionoccursevenifexprisfalseandcommandisthusnotexecutedthisisabug.
if(expr)then
...
elseif(expr2)then
...
else
...
endif
Ifthespecifiedexpristruethenthecommandstothefirstelseareexecutedotherwiseifexpr2istruethenthecommandstothesecondelseare
executed,etc.Anynumberofelseifpairsarepossibleonlyoneendifisneeded.Theelsepartislikewiseoptional.(Thewordselseandendifmustappear
atthebeginningofinputlinestheifmustappearaloneonitsinputlineorafteranelse.)
inlibsharedlibrary...(+)
Addseachsharedlibrarytothecurrentenvironment.Thereisnowaytoremoveasharedlibrary.(Domain/OSonly)

http://linux.about.com/library/cmd/blcmdl1_csh.htm

26/43

10/24/2015

cshLinuxCommandUnixCommand

jobs[l]
Liststheactivejobs.Withl,listsprocessIDsinadditiontothenormalinformation.OnTCFsystems,printsthesiteonwhicheachjobisexecuting.
kill[ssignal]%job|pid...
killl
Thefirstandsecondformssendsthespecifiedsignal(or,ifnoneisgiven,theTERM(terminate)signal)tothespecifiedjobsorprocesses.jobmaybea
number,astring,`',`%',`+'or`'asdescribedunderJobs.Signalsareeithergivenbynumberorbyname(asgivenin/usr/include/signal.h,stripped
oftheprefix`SIG').Thereisnodefaultjobsayingjust`kill'doesnotsendasignaltothecurrentjob.IfthesignalbeingsentisTERM(terminate)or
HUP(hangup),thenthejoborprocessissentaCONT(continue)signalaswell.Thethirdformliststhesignalnames.
limit[h][resource[maximumuse]]
Limitstheconsumptionbythecurrentprocessandeachprocessitcreatestonotindividuallyexceedmaximumuseonthespecifiedresource.Ifno
maximumuseisgiven,thenthecurrentlimitisprintedifnoresourceisgiven,thenalllimitationsaregiven.Ifthehflagisgiven,thehardlimitsare
usedinsteadofthecurrentlimits.Thehardlimitsimposeaceilingonthevaluesofthecurrentlimits.Onlythesuperusermayraisethehardlimits,but
ausermaylowerorraisethecurrentlimitswithinthelegalrange.
Controllableresourcescurrentlyinclude(ifsupportedbytheOS):
cputime
themaximumnumberofcpusecondstobeusedbyeachprocess
filesize
thelargestsinglefilewhichcanbecreated
datasize
themaximumgrowthofthedata+stackregionviasbrk(2)beyondtheendoftheprogramtext
stacksize
themaximumsizeoftheautomaticallyextendedstackregion
coredumpsize
thesizeofthelargestcoredumpthatwillbecreated
memoryuse
themaximumamountofphysicalmemoryaprocessmayhaveallocatedtoitatagiventime
descriptorsoropenfiles
themaximumnumberofopenfilesforthisprocess
concurrency
themaximumnumberofthreadsforthisprocess
memorylocked
themaximumsizewhichaprocessmaylockintomemoryusingmlock(2)
maxproc
themaximumnumberofsimultaneousprocessesforthisuserid
sbsize
themaximumsizeofsocketbufferusageforthisuser
maximumusemaybegivenasa(floatingpointorinteger)numberfollowedbyascalefactor.Foralllimitsotherthancputimethedefaultscaleis
`k'or`kilobytes'(1024bytes)ascalefactorof`m'or`megabytes'mayalsobeused.Forcputimethedefaultscalingis`seconds',while`m'for
minutesor`h'forhours,oratimeoftheform`mm:ss'givingminutesandsecondsmaybeused.
Forbothresourcenamesandscalefactors,unambiguousprefixesofthenamessuffice.
log(+)
Printsthewatchshellvariableandreportsoneachuserindicatedinwatchwhoisloggedin,regardlessofwhentheylastloggedin.Seealsowatchlog.
login
Terminatesaloginshell,replacingitwithaninstanceof/bin/login.Thisisonewaytologoff,includedforcompatibilitywithsh(1).
logout
Terminatesaloginshell.Especiallyusefulifignoreeofisset.
lsF[switch...][file...](+)
Listsfileslike`lsF',butmuchfaster.Itidentifieseachtypeofspecialfileinthelistingwithaspecialcharacter:
/
Directory

http://linux.about.com/library/cmd/blcmdl1_csh.htm

27/43

10/24/2015

cshLinuxCommandUnixCommand

*
Executable
#
Blockdevice
%
Characterdevice
|
Namedpipe(systemswithnamedpipesonly)
=
Socket(systemswithsocketsonly)
@
Symboliclink(systemswithsymboliclinksonly)
+
Hiddendirectory(AIXonly)orcontextdependent(HP/UXonly)
:
Networkspecial(HP/UXonly)
Ifthelistlinksshellvariableisset,symboliclinksareidentifiedinmoredetail(ononlysystemsthathavethem,ofcourse):
@
Symboliclinktoanondirectory
>
Symboliclinktoadirectory
&
Symboliclinktonowhere
listlinksalsoslowsdownlsFandcausespartitionsholdingfilespointedtobysymboliclinkstobemounted.
Ifthelistflagsshellvariableissetto`x',`a'or`A',oranycombinationthereof(e.g.,`xA'),theyareusedasflagstolsF,makingitactlike`lsxF',`ls
Fa',`lsFA'oracombination(e.g.,`lsFxA').Onmachineswhere`lsC'isnotthedefault,lsFactslike`lsCF',unlesslistflagscontainsan`x',in
whichcaseitactslike`lsxF'.lsFpassesitsargumentstols(1)ifitisgivenanyswitches,so`aliaslslsF'generallydoestherightthing.
ThelsFbuiltincanlistfilesusingdifferentcolorsdependingonthefiletypeorextension.SeethecolortcshvariableandtheLS_COLORSenvironment
variable.
migrate[site]pid|%jobid...(+)
migratesite(+)
Thefirstformmigratestheprocessorjobtothesitespecifiedorthedefaultsitedeterminedbythesystempath.Thesecondformisequivalentto
`migratesite$$':itmigratesthecurrentprocesstothespecifiedsite.Migratingtheshellitselfcancauseunexpectedbehavior,becausetheshelldoes
notliketoloseitstty.(TCFonly)
newgrp[]group(+)
Equivalentto`execnewgrp'seenewgrp(1).Availableonlyiftheshellwassocompiledseetheversionshellvariable.
nice[+number][command]
Setstheschedulingpriorityfortheshelltonumber,or,withoutnumber,to4.Withcommand,runscommandattheappropriatepriority.Thegreaterthe
number,thelesscputheprocessgets.Thesuperusermayspecifynegativeprioritybyusing`nicenumber...'.Commandisalwaysexecutedinasub
shell,andtherestrictionsplacedoncommandsinsimpleifstatementsapply.
nohup[command]
Withcommand,runscommandsuchthatitwillignorehangupsignals.Notethatcommandsmaysettheirownresponsetohangups,overridingnohup.
Withoutanargument(allowedinonlyashellscript),causestheshelltoignorehangupsfortheremainderofthescript.SeealsoSignalhandlingand
thehupbuiltincommand.
notify[%job...]
Causestheshelltonotifytheuserasynchronouslywhenthestatusofanyofthespecifiedjobs(or,without%job,thecurrentjob)changes,insteadof
waitinguntilthenextpromptasisusual.jobmaybeanumber,astring,`',`%',`+'or`'asdescribedunderJobs.Seealsothenotifyshellvariable.
onintr[|label]
Controlstheactionoftheshelloninterrupts.Withoutarguments,restoresthedefaultactionoftheshelloninterrupts,whichistoterminateshellscripts
ortoreturntotheterminalcommandinputlevel.With`',causesallinterruptstobeignored.Withlabel,causestheshelltoexecutea`gotolabel'when
aninterruptisreceivedorachildprocessterminatesbecauseitwasinterrupted.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

28/43

10/24/2015

cshLinuxCommandUnixCommand

onintrisignorediftheshellisrunningdetachedandinsystemstartupfiles(seeFILES),whereinterruptsaredisabledanyway.
popd[p][l][n|v][+n]
Withoutarguments,popsthedirectorystackandreturnstothenewtopdirectory.Withanumber`+n',discardsthen'thentryinthestack.
Finally,allformsofpopdprintthefinaldirectorystack,justlikedirs.Thepushdsilentshellvariablecanbesettopreventthisandthepflagcanbe
giventooverridepushdsilent.Thel,nandvflagshavethesameeffectonpopdasondirs.(+)
printenv[name](+)
Printsthenamesandvaluesofallenvironmentvariablesor,withname,thevalueoftheenvironmentvariablename.
pushd[p][l][n|v][name|+n]
Withoutarguments,exchangesthetoptwoelementsofthedirectorystack.Ifpushdtohomeisset,pushdwithoutargumentsdoes`pushd~',likecd.
(+)Withname,pushesthecurrentworkingdirectoryontothedirectorystackandchangestoname.Ifnameis`'itisinterpretedastheprevious
workingdirectory(seeFilenamesubstitution).(+)Ifduniqueisset,pushdremovesanyinstancesofnamefromthestackbeforepushingitontothe
stack.(+)Withanumber`+n',rotatesthenthelementofthedirectorystackaroundtobethetopelementandchangestoit.Ifdextractisset,
however,`pushd+n'extractsthenthdirectory,pushesitontothetopofthestackandchangestoit.(+)
Finally,allformsofpushdprintthefinaldirectorystack,justlikedirs.Thepushdsilentshellvariablecanbesettopreventthisandthepflagcanbe
giventooverridepushdsilent.Thel,nandvflagshavethesameeffectonpushdasondirs.(+)
rehash
Causestheinternalhashtableofthecontentsofthedirectoriesinthepathvariabletoberecomputed.Thisisneededifnewcommandsareaddedto
directoriesinpathwhileyouareloggedin.Thisshouldbenecessaryonlyifyouaddcommandstooneofyourowndirectories,orifasystems
programmerchangesthecontentsofoneofthesystemdirectories.Alsoflushesthecacheofhomedirectoriesbuiltbytildeexpansion.
repeatcountcommand
Thespecifiedcommand,whichissubjecttothesamerestrictionsasthecommandintheonelineifstatementabove,isexecutedcounttimes.I/O
redirectionsoccurexactlyonce,evenifcountis0.
rootnode//nodename(+)
Changestherootnodeto//nodename,sothat`/'willbeinterpretedas`//nodename'.(Domain/OSonly)
sched(+)
sched[+]hh:mmcommand(+)
schedn(+)
Thefirstformprintsthescheduledeventlist.Theschedshellvariablemaybesettodefinetheformatinwhichthescheduledeventlistisprinted.The
secondformaddscommandtothescheduledeventlist.Forexample,
>sched11:00echoIt\'seleveno\'clock.
causestheshelltoecho`It'seleveno'clock.'at11AM.Thetimemaybein12hourAM/PMformat
>sched5pmsetprompt='[%h]It\'safter5gohome:>'
ormayberelativetothecurrenttime:
>sched+2:15/usr/lib/uucp/uucicor1sother
ArelativetimespecificationmaynotuseAM/PMformat.Thethirdformremovesitemnfromtheeventlist:
>sched
1WedApr415:42/usr/lib/uucp/uucicor1sother
2WedApr417:00setprompt=[%h]It'safter5gohome:>
>sched2
>sched
1WedApr415:42/usr/lib/uucp/uucicor1sother
Acommandinthescheduledeventlistisexecutedjustbeforethefirstpromptisprintedafterthetimewhenthecommandisscheduled.Itis
possibletomisstheexacttimewhenthecommandistoberun,butanoverduecommandwillexecuteatthenextprompt.Acommandwhich
comesduewhiletheshelliswaitingforuserinputisexecutedimmediately.However,normaloperationofanalreadyrunningcommandwillnotbe
interruptedsothatascheduledeventlistelementmayberun.
Thismechanismissimilarto,butnotthesameas,theat(1)commandonsomeUnixsystems.Itsmajordisadvantageisthatitmaynotruna
commandatexactlythespecifiedtime.Itsmajoradvantageisthatbecauseschedrunsdirectlyfromtheshell,ithasaccesstoshellvariablesand
otherstructures.Thisprovidesamechanismforchangingone'sworkingenvironmentbasedonthetimeofday.
set

http://linux.about.com/library/cmd/blcmdl1_csh.htm

29/43

10/24/2015

cshLinuxCommandUnixCommand

setname...
setname=word...
set[r][f|l]name=(wordlist)...(+)
setname[index]=word...
setr(+)
setrname...(+)
setrname=word...(+)
Thefirstformofthecommandprintsthevalueofallshellvariables.Variableswhichcontainmorethanasinglewordprintasaparenthesizedwordlist.
Thesecondformsetsnametothenullstring.Thethirdformsetsnametothesingleword.Thefourthformsetsnametothelistofwordsinwordlist.In
allcasesthevalueiscommandandfilenameexpanded.Ifrisspecified,thevalueissetreadonly.Ifforlarespecified,setonlyuniquewordskeeping
theirorder.fprefersthefirstoccurrenceofaword,andlthelast.Thefifthformsetstheindex'thcomponentofnametowordthiscomponentmust
alreadyexist.Thesixthformlistsonlythenamesofallshellvariablesthatarereadonly.Theseventhformmakesnamereadonly,whetherornotithas
avalue.Thesecondformsetsnametothenullstring.Theeighthformisthesameasthethirdform,butmakenamereadonlyatthesametime.
Theseargumentscanberepeatedtosetand/ormakereadonlymultiplevariablesinasinglesetcommand.Note,however,thatvariableexpansion
happensforallargumentsbeforeanysettingoccurs.Notealsothat`='canbeadjacenttobothnameandwordorseparatedfrombothbywhitespace,
butcannotbeadjacenttoonlyoneortheother.Seealsotheunsetbuiltincommand.
setenv[name[value]]
Withoutarguments,printsthenamesandvaluesofallenvironmentvariables.Givenname,setstheenvironmentvariablenametovalueor,without
value,tothenullstring.
setpathpath(+)
Equivalenttosetpath(1).(Machonly)
setspathLOCAL|site|cpu...(+)
Setsthesystemexecutionpath.(TCFonly)
settccapvalue(+)
Tellstheshelltobelievethattheterminalcapabilitycap(asdefinedintermcap(5))hasthevaluevalue.Nosanitycheckingisdone.Conceptterminal
usersmayhaveto`settcxnno'togetproperwrappingattherightmostcolumn.
setty[d|q|x][a][[+|]mode](+)
Controlswhichttymodes(seeTerminalmanagement)theshelldoesnotallowtochange.d,qorxtellssettytoactonthe`edit',`quote'or
`execute'setofttymodesrespectivelywithoutd,qorx,`execute'isused.
Withoutotherarguments,settyliststhemodesinthechosensetwhicharefixedon(`+mode')oroff(`mode').Theavailablemodes,andthusthe
display,varyfromsystemtosystem.Witha,listsallttymodesinthechosensetwhetherornottheyarefixed.With+mode,modeormode,fixes
modeonorofforremovescontrolfrommodeinthechosenset.Forexample,`setty+echokechoe'fixes`echok'modeonandallowscommandstoturn
`echoe'modeonoroff,bothwhentheshellisexecutingcommands.
setxvers[string](+)
Settheexperimentalversionprefixtostring,orremovesitifstringisomitted.(TCFonly)
shift[variable]
Withoutarguments,discardsargv[1]andshiftsthemembersofargvtotheleft.Itisanerrorforargvnottobesetortohavelessthanonewordas
value.Withvariable,performsthesamefunctiononvariable.
source[h]name[args...]
Theshellreadsandexecutescommandsfromname.Thecommandsarenotplacedonthehistorylist.Ifanyargsaregiven,theyareplacedinargv.(+)
sourcecommandsmaybenestediftheyarenestedtoodeeplytheshellmayrunoutoffiledescriptors.Anerrorinasourceatanylevelterminatesall
nestedsourcecommands.Withh,commandsareplacedonthehistorylistinsteadofbeingexecuted,muchlike`historyL'.
stop%job|pid...
Stopsthespecifiedjobsorprocesseswhichareexecutinginthebackground.jobmaybeanumber,astring,`',`%',`+'or`'asdescribedunderJobs.
Thereisnodefaultjobsayingjust`stop'doesnotstopthecurrentjob.
suspend
Causestheshelltostopinitstracks,muchasifithadbeensentastopsignalwith^Z.Thisismostoftenusedtostopshellsstartedbysu(1).
switch(string)
casestr1:
...
breaksw
...
default:
...

http://linux.about.com/library/cmd/blcmdl1_csh.htm

30/43

10/24/2015

cshLinuxCommandUnixCommand

breaksw
endsw
Eachcaselabelissuccessivelymatched,againstthespecifiedstringwhichisfirstcommandandfilenameexpanded.Thefilemetacharacters`*',`?'and
`[...]'maybeusedinthecaselabels,whicharevariableexpanded.Ifnoneofthelabelsmatchbeforea`default'labelisfound,thentheexecution
beginsafterthedefaultlabel.Eachcaselabelandthedefaultlabelmustappearatthebeginningofaline.Thecommandbreakswcausesexecutionto
continueaftertheendsw.OtherwisecontrolmayfallthroughcaselabelsanddefaultlabelsasinC.Ifnolabelmatchesandthereisnodefault,execution
continuesaftertheendsw.
telltc(+)
Liststhevaluesofallterminalcapabilities(seetermcap(5)).
time[command]
Executescommand(whichmustbeasimplecommand,notanalias,apipeline,acommandlistoraparenthesizedcommandlist)andprintsatime
summaryasdescribedunderthetimevariable.Ifnecessary,anextrashelliscreatedtoprintthetimestatisticwhenthecommandcompletes.Without
command,printsatimesummaryforthecurrentshellanditschildren.
umask[value]
Setsthefilecreationmasktovalue,whichisgiveninoctal.Commonvaluesforthemaskare002,givingallaccesstothegroupandreadandexecute
accesstoothers,and022,givingreadandexecuteaccesstothegroupandothers.Withoutvalue,printsthecurrentfilecreationmask.
unaliaspattern
Removesallaliaseswhosenamesmatchpattern.`unalias*'thusremovesallaliases.Itisnotanerrorfornothingtobeunaliased.
uncompletepattern(+)
Removesallcompletionswhosenamesmatchpattern.`uncomplete*'thusremovesallcompletions.Itisnotanerrorfornothingtobeuncompleted.
unhash
Disablesuseoftheinternalhashtabletospeedlocationofexecutedprograms.
universeuniverse(+)
Setstheuniversetouniverse.(Masscomp/RTUonly)
unlimit[h][resource]
Removesthelimitationonresourceor,ifnoresourceisspecified,allresourcelimitations.Withh,thecorrespondinghardlimitsareremoved.Onlythe
superusermaydothis.
unsetpattern
Removesallvariableswhosenamesmatchpattern,unlesstheyarereadonly.`unset*'thusremovesallvariablesunlesstheyarereadonlythisisa
badidea.Itisnotanerrorfornothingtobeunset.
unsetenvpattern
Removesallenvironmentvariableswhosenamesmatchpattern.`unsetenv*'thusremovesallenvironmentvariablesthisisabadidea.Itisnotan
errorfornothingtobeunsetenved.
ver[systype[command]](+)
Withoutarguments,printsSYSTYPE.Withsystype,setsSYSTYPEtosystype.Withsystypeandcommand,executescommandundersystype.systype
maybe`bsd4.3'or`sys5.3'.(Domain/OSonly)
wait
Theshellwaitsforallbackgroundjobs.Iftheshellisinteractive,aninterruptwilldisruptthewaitandcausetheshelltoprintthenamesandjob
numbersofalloutstandingjobs.
warpuniverse(+)
Setstheuniversetouniverse.(Convex/OSonly)
watchlog(+)
Analternatenameforthelogbuiltincommand(q.v.).Availableonlyiftheshellwassocompiledseetheversionshellvariable.
wherecommand(+)
Reportsallknowninstancesofcommand,includingaliases,builtinsandexecutablesinpath.
whichcommand(+)
Displaysthecommandthatwillbeexecutedbytheshellaftersubstitutions,pathsearching,etc.Thebuiltincommandisjustlikewhich(1),butit
correctlyreportstcshaliasesandbuiltinsandis10to100timesfaster.Seealsothewhichcommandeditorcommand.
while(expr)
...
end
Executesthecommandsbetweenthewhileandthematchingendwhileexpr(anexpression,asdescribedunderExpressions)evaluatesnonzero.while

http://linux.about.com/library/cmd/blcmdl1_csh.htm

31/43

10/24/2015

cshLinuxCommandUnixCommand

andendmustappearaloneontheirinputlines.breakandcontinuemaybeusedtoterminateorcontinuetheloopprematurely.Iftheinputisa
terminal,theuserispromptedthefirsttimethroughtheloopaswithforeach.

Specialaliases(+)
Ifset,eachofthesealiasesexecutesautomaticallyattheindicatedtime.Theyareallinitiallyundefined.
beepcmd
Runswhentheshellwantstoringtheterminalbell.
cwdcmd
Runsaftereverychangeofworkingdirectory.Forexample,iftheuserisworkingonanXwindowsystemusingxterm(1)andareparentingwindow
managerthatsupportstitlebarssuchastwm(1)anddoes
>aliascwdcmd'echon"^[]2${HOST}:$cwd^G"'
thentheshellwillchangethetitleoftherunningxterm(1)tobethenameofthehost,acolon,andthefullcurrentworkingdirectory.Afancier
waytodothatis
>aliascwdcmd'echon"^[]2${HOST}:$cwd^G^[]1${HOST}^G"'
Thiswillputthehostnameandworkingdirectoryonthetitlebarbutonlythehostnameintheiconmanagermenu.
Notethatputtingacd,pushdorpopdincwdcmdmaycauseaninfiniteloop.Itistheauthor'sopinionthatanyonedoingsowillgetwhatthey
deserve.
jobcmd
Runsbeforeeachcommandgetsexecuted,orwhenthecommandchangesstate.Thisissimilartopostcmd,butitdoesnotprintbuiltins.
>aliasjobcmd'echon"^[]2\\!#^G"'
thenexecutingvifoo.cwillputthecommandstringinthextermtitlebar.
helpcommand
Invokedbytherunhelpeditorcommand.Thecommandnameforwhichhelpissoughtispassedassoleargument.Forexample,ifonedoes
>aliashelpcommand'\!:1help'
thenthehelpdisplayofthecommanditselfwillbeinvoked,usingtheGNUhelpcallingconvention.Currentlythereisnoeasywaytoaccountfor
variouscallingconventions(e.g.,thecustomaryUnix`h'),exceptbyusingatableofmanycommands.
periodic
Runseverytperiodminutes.Thisprovidesaconvenientmeansforcheckingoncommonbutinfrequentchangessuchasnewmail.Forexample,ifone
does
>settperiod=30
>aliasperiodicchecknews
thenthechecknews(1)programrunsevery30minutes.Ifperiodicissetbuttperiodisunsetorsetto0,periodicbehaveslikeprecmd.
precmd
Runsjustbeforeeachpromptisprinted.Forexample,ifonedoes
>aliasprecmddate
thendate(1)runsjustbeforetheshellpromptsforeachcommand.Therearenolimitsonwhatprecmdcanbesettodo,butdiscretionshouldbe
used.
postcmd
Runsbeforeeachcommandgetsexecuted.
>aliaspostcmd'echon"^[]2\\!#^G"'
thenexecutingvifoo.cwillputthecommandstringinthextermtitlebar.
shell
Specifiestheinterpreterforexecutablescriptswhichdonotthemselvesspecifyaninterpreter.Thefirstwordshouldbeafullpathnametothedesired
interpreter(e.g.,`/bin/csh'or`/usr/local/bin/tcsh').

http://linux.about.com/library/cmd/blcmdl1_csh.htm

32/43

10/24/2015

cshLinuxCommandUnixCommand

Specialshellvariables
Thevariablesdescribedinthissectionhavespecialmeaningtotheshell.
Theshellsetsaddsuffix,argv,autologout,command,echo_style,edit,gid,group,home,loginsh,oid,path,prompt,prompt2,prompt3,shell,
shlvl,tcsh,term,tty,uid,userandversionatstartuptheydonotchangethereafterunlesschangedbytheuser.Theshellupdatescwd,dirstack,owd
andstatuswhennecessary,andsetslogoutonlogout.
Theshellsynchronizesafsuser,group,home,path,shlvl,termanduserwiththeenvironmentvariablesofthesamenames:whenevertheenvironment
variablechangestheshellchangesthecorrespondingshellvariabletomatch(unlesstheshellvariableisreadonly)andviceversa.Notethatalthoughcwd
andPWDhaveidenticalmeanings,theyarenotsynchronizedinthismanner,andthattheshellautomaticallyinterconvertsthedifferentformatsofpathand
PATH.
addsuffix(+)
Ifset,filenamecompletionadds`/'totheendofdirectoriesandaspacetotheendofnormalfileswhentheyarematchedexactly.Setbydefault.
afsuser(+)
Ifset,autologout'sautolockfeatureusesitsvalueinsteadofthelocalusernameforkerberosauthentication.
ampm(+)
Ifset,alltimesareshownin12hourAM/PMformat.
argv
Theargumentstotheshell.Positionalparametersaretakenfromargv,i.e.,`$1'isreplacedby`$argv[1]',etc.Setbydefault,butusuallyemptyin
interactiveshells.
autocorrect(+)
Ifset,thespellwordeditorcommandisinvokedautomaticallybeforeeachcompletionattempt.
autoexpand(+)
Ifset,theexpandhistoryeditorcommandisinvokedautomaticallybeforeeachcompletionattempt.
autolist(+)
Ifset,possibilitiesarelistedafteranambiguouscompletion.Ifsetto`ambiguous',possibilitiesarelistedonlywhennonewcharactersareaddedby
completion.
autologout(+)
Thefirstwordisthenumberofminutesofinactivitybeforeautomaticlogout.Theoptionalsecondwordisthenumberofminutesofinactivitybefore
automaticlocking.Whentheshellautomaticallylogsout,itprints`autologout',setsthevariablelogoutto`automatic'andexits.Whentheshell
automaticallylocks,theuserisrequiredtoenterhispasswordtocontinueworking.Fiveincorrectattemptsresultinautomaticlogout.Setto`60'
(automaticlogoutafter60minutes,andnolocking)bydefaultinloginandsuperusershells,butnotiftheshellthinksitisrunningunderawindow
system(i.e.,theDISPLAYenvironmentvariableisset),thettyisapseudotty(pty)ortheshellwasnotsocompiled(seetheversionshellvariable).
Seealsotheafsuserandlogoutshellvariables.
backslash_quote(+)
Ifset,backslashes(`\')alwaysquote`\',`'',and`"'.Thismaymakecomplexquotingtaskseasier,butitcancausesyntaxerrorsincsh(1)scripts.
catalog
Thefilenameofthemessagecatalog.Ifset,tcshuse`tcsh.${catalog}'asamessagecataloginsteadofdefault`tcsh'.
cdpath
Alistofdirectoriesinwhichcdshouldsearchforsubdirectoriesiftheyaren'tfoundinthecurrentdirectory.
color
Ifset,itenablescolordisplayforthebuiltinlsFanditpassescolor=autotols.Alternatively,itcanbesettoonlylsForonlylstoenablecolorto
onlyonecommand.Settingittonothingisequivalenttosettingitto(lsFls).
colorcat
Ifset,itenablescolorescapesequenceforNLSmessagefiles.AnddisplaycolorfulNLSmessages.
command(+)
Ifset,thecommandwhichwaspassedtotheshellwiththecflag(q.v.).
complete(+)
Ifsetto`enhance',completion1)ignorescaseand2)considersperiods,hyphensandunderscores(`.',`'and`_')tobewordseparatorsandhyphens
andunderscorestobeequivalent.
continue(+)
Ifsettoalistofcommands,theshellwillcontinuethelistedcommands,insteadofstartinganewone.
continue_args(+)
Sameascontinue,buttheshellwillexecute:

http://linux.about.com/library/cmd/blcmdl1_csh.htm

33/43

10/24/2015

cshLinuxCommandUnixCommand
echo`pwd`$argv>~/.<cmd>_pause%<cmd>

correct(+)
Ifsetto`cmd',commandsareautomaticallyspellingcorrected.Ifsetto`complete',commandsareautomaticallycompleted.Ifsetto`all',theentire
commandlineiscorrected.
cwd
Thefullpathnameofthecurrentdirectory.Seealsothedirstackandowdshellvariables.
dextract(+)
Ifset,`pushd+n'extractsthenthdirectoryfromthedirectorystackratherthanrotatingittothetop.
dirsfile(+)
Thedefaultlocationinwhich`dirsS'and`dirsL'lookforahistoryfile.Ifunset,~/.cshdirsisused.Becauseonly~/.tcshrcisnormallysourcedbefore
~/.cshdirs,dirsfileshouldbesetin~/.tcshrcratherthan~/.login.
dirstack(+)
Anarrayofallthedirectoriesonthedirectorystack.`$dirstack[1]'isthecurrentworkingdirectory,`$dirstack[2]'thefirstdirectoryonthestack,etc.
Notethatthecurrentworkingdirectoryis`$dirstack[1]'but`=0'indirectorystacksubstitutions,etc.Onecanchangethestackarbitrarilybysetting
dirstack,butthefirstelement(thecurrentworkingdirectory)isalwayscorrect.Seealsothecwdandowdshellvariables.
dspmbyte(+)
Ifsetto`euc',itenablesdisplayandeditingEUCkanji(Japanese)code.Ifsetto`sjis',itenablesdisplayandeditingShiftJIS(Japanese)code.Ifsetto
`big5',itenablesdisplayandeditingBig5(Chinese)code.Ifsetto`utf8',itenablesdisplayandeditingUtf8(Unicode)code.Ifsettothefollowingformat,
itenablesdisplayandeditingoforiginalmultibytecodeformat:
>setdspmbyte=0000....(256bytes)....0000
Thetablerequiresjust256bytes.Eachcharacterof256characterscorresponds(fromlefttoright)totheASCIIcodes0x00,0x01,...0xff.Each
characterissettonumber0,1,2and3.Eachnumberhasthefollowingmeaning:
0...notusedformultibytecharacters.
1...usedforthefirstbyteofamultibytecharacter.
2...usedforthesecondbyteofamultibytecharacter.
3...usedforboththefirstbyteandsecondbyteofamultibytecharacter.

Example:
Ifsetto`001322',thefirstcharacter(means0x00oftheASCIIcode)andsecondcharacter(means0x01ofASCIIcode)aresetto`0'.Then,itis
notusedformultibytecharacters.The3rdcharacter(0x02)issetto'2',indicatingthatitisusedforthefirstbyteofamultibytecharacter.The
4thcharacter(0x03)isset'3'.Itisusedforboththefirstbyteandthesecondbyteofamultibytecharacter.The5thand6thcharacters
(0x04,0x05)aresetto'2',indicatingthattheyareusedforthesecondbyteofamultibytecharacter.
TheGNUfileutilsversionoflscannotdisplaymultibytefilenameswithouttheN(literal)option.Ifyouareusingthisversion,setthesecond
wordofdspmbyteto"ls".Ifnot,forexample,"lsFl"cannotdisplaymultibytefilenames.

Note:
ThisvariablecanonlybeusedifKANJIandDSPMBYTEhasbeendefinedatcompiletime.
dunique(+)
Ifset,pushdremovesanyinstancesofnamefromthestackbeforepushingitontothestack.
echo
Ifset,eachcommandwithitsargumentsisechoedjustbeforeitisexecuted.Fornonbuiltincommandsallexpansionsoccurbeforeechoing.Builtin
commandsareechoedbeforecommandandfilenamesubstitution,becausethesesubstitutionsarethendoneselectively.Setbythexcommandline
option.
echo_style(+)
Thestyleoftheechobuiltin.Maybesetto
bsd
Don'techoanewlineifthefirstargumentis`n'.
sysv
Recognizebackslashedescapesequencesinechostrings.
both
Recognizeboththe`n'flagandbackslashedescapesequencesthedefault.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

34/43

10/24/2015

cshLinuxCommandUnixCommand

none
Recognizeneither.
Setbydefaulttothelocalsystemdefault.TheBSDandSystemVoptionsaredescribedintheecho(1)manpagesontheappropriatesystems.
edit(+)
Ifset,thecommandlineeditorisused.Setbydefaultininteractiveshells.
ellipsis(+)
Ifset,the`%c'/`%.'and`%C'promptsequences(seethepromptshellvariable)indicateskippeddirectorieswithanellipsis(`...')insteadof
`/<skipped>'.
fignore(+)
Listsfilenamesuffixestobeignoredbycompletion.
filec
Intcsh,completionisalwaysusedandthisvariableisignoredbydefault.Ifeditisunset,thenthetraditionalcshcompletionisused.Ifsetincsh,
filenamecompletionisused.
gid(+)
Theuser'srealgroupID.
group(+)
Theuser'sgroupname.
histchars
AstringvaluedeterminingthecharactersusedinHistorysubstitution(q.v.).Thefirstcharacterofitsvalueisusedasthehistorysubstitution
character,replacingthedefaultcharacter`!'.Thesecondcharacterofitsvaluereplacesthecharacter`^'inquicksubstitutions.
histdup(+)
Controlshandlingofduplicateentriesinthehistorylist.Ifsetto`all'onlyuniquehistoryeventsareenteredinthehistorylist.Ifsetto`prev'andthe
lasthistoryeventisthesameasthecurrentcommand,thenthecurrentcommandisnotenteredinthehistory.Ifsetto`erase'andthesameeventis
foundinthehistorylist,thatoldeventgetserasedandthecurrentonegetsinserted.Notethatthe`prev'and`all'optionsrenumberhistoryeventsso
therearenogaps.
histfile(+)
Thedefaultlocationinwhich`historyS'and`historyL'lookforahistoryfile.Ifunset,~/.historyisused.histfileisusefulwhensharingthesame
homedirectorybetweendifferentmachines,orwhensavingseparatehistoriesondifferentterminals.Becauseonly~/.tcshrcisnormallysourcedbefore
~/.history,histfileshouldbesetin~/.tcshrcratherthan~/.login.
histlit(+)
Ifset,builtinandeditorcommandsandthesavehistmechanismusetheliteral(unexpanded)formoflinesinthehistorylist.Seealsothetoggleliteral
historyeditorcommand.
history
Thefirstwordindicatesthenumberofhistoryeventstosave.Theoptionalsecondword(+)indicatestheformatinwhichhistoryisprintedifnotgiven,
`%h\t%T\t%R\n'isused.Theformatsequencesaredescribedbelowunderpromptnotethevariablemeaningof`%R'.Setto`100'bydefault.
home
Initializedtothehomedirectoryoftheinvoker.Thefilenameexpansionof`~'referstothisvariable.
ignoreeof
Ifsettotheemptystringor`0'andtheinputdeviceisaterminal,theendoffilecommand(usuallygeneratedbytheuserbytyping`^D'onanempty
line)causestheshelltoprint`Use"exit"toleavetcsh.'insteadofexiting.Thispreventstheshellfromaccidentallybeingkilled.Ifsettoanumbern,the
shellignoresn1consecutiveendoffilesandexitsonthenth.(+)Ifunset,`1'isused,i.e.,theshellexitsonasingle`^D'.
implicitcd(+)
Ifset,theshelltreatsadirectorynametypedasacommandasthoughitwerearequesttochangetothatdirectory.Ifsettoverbose,thechangeof
directoryisechoedtothestandardoutput.Thisbehaviorisinhibitedinnoninteractiveshellscripts,orforcommandstringswithmorethanoneword.
Changingdirectorytakesprecedenceoverexecutingalikenamedcommand,butitisdoneafteraliassubstitutions.Tildeandvariableexpansionsworkas
expected.
inputmode(+)
Ifsetto`insert'or`overwrite',putstheeditorintothatinputmodeatthebeginningofeachline.
killdup(+)
Controlshandlingofduplicateentriesinthekillring.Ifsetto`all'onlyuniquestringsareenteredinthekillring.Ifsetto`prev'andthelastkilledstring
isthesameasthecurrentkilledstring,thenthecurrentstringisnotenteredinthering.Ifsetto`erase'andthesamestringisfoundinthekillring,
theoldstringiserasedandthecurrentoneisinserted.
killring(+)
Indicatesthenumberofkilledstringstokeepinmemory.Setto`30'bydefault.Ifunsetorsettolessthan`2',theshellwillonlykeepthemost

http://linux.about.com/library/cmd/blcmdl1_csh.htm

35/43

10/24/2015

cshLinuxCommandUnixCommand

recentlykilledstring.
listflags(+)
Ifsetto`x',`a'or`A',oranycombinationthereof(e.g.,`xA'),theyareusedasflagstolsF,makingitactlike`lsxF',`lsFa',`lsFA'oracombination
(e.g.,`lsFxA'):`a'showsallfiles(eveniftheystartwitha`.'),`A'showsallfilesbut`.'and`..',and`x'sortsacrossinsteadofdown.Ifthesecond
wordoflistflagsisset,itisusedasthepathto`ls(1)'.
listjobs(+)
Ifset,alljobsarelistedwhenajobissuspended.Ifsetto`long',thelistingisinlongformat.
listlinks(+)
Ifset,thelsFbuiltincommandshowsthetypeoffiletowhicheachsymboliclinkpoints.
listmax(+)
Themaximumnumberofitemswhichthelistchoiceseditorcommandwilllistwithoutaskingfirst.
listmaxrows(+)
Themaximumnumberofrowsofitemswhichthelistchoiceseditorcommandwilllistwithoutaskingfirst.
loginsh(+)
Setbytheshellifitisaloginshell.Settingorunsettingitwithinashellhasnoeffect.Seealsoshlvl.
logout(+)
Setbytheshellto`normal'beforeanormallogout,`automatic'beforeanautomaticlogout,and`hangup'iftheshellwaskilledbyahangupsignal(see
Signalhandling).Seealsotheautologoutshellvariable.
mail
Thenamesofthefilesordirectoriestocheckforincomingmail,separatedbywhitespace,andoptionallyprecededbyanumericword.Beforeeach
prompt,if10minuteshavepassedsincethelastcheck,theshellcheckseachfileandsays`Youhavenewmail.'(or,ifmailcontainsmultiplefiles,`You
havenewmailinname.')ifthefilesizeisgreaterthanzeroinsizeandhasamodificationtimegreaterthanitsaccesstime.
Ifyouareinaloginshell,thennomailfileisreportedunlessithasbeenmodifiedafterthetimetheshellhasstartedup,topreventredundant
notifications.Mostloginprogramswilltellyouwhetherornotyouhavemailwhenyoulogin.
Ifafilespecifiedinmailisadirectory,theshellwillcounteachfilewithinthatdirectoryasaseparatemessage,andwillreport`Youhavenmails.'or
`Youhavenmailsinname.'asappropriate.Thisfunctionalityisprovidedprimarilyforthosesystemswhichstoremailinthismanner,suchasthe
AndrewMailSystem.
Ifthefirstwordofmailisnumericitistakenasadifferentmailcheckinginterval,inseconds.
Underveryrarecircumstances,theshellmayreport`Youhavemail.'insteadof`Youhavenewmail.'
matchbeep(+)
Ifsetto`never',completionneverbeeps.Ifsetto`nomatch',itbeepsonlywhenthereisnomatch.Ifsetto`ambiguous,itbeepswhenthereare
multiplematches.Ifsetto`notunique',itbeepswhenthereisoneexactandotherlongermatches.Ifunset,`ambiguous'isused.
nobeep(+)
Ifset,beepingiscompletelydisabled.Seealsovisiblebell.
noclobber
Ifset,restrictionsareplacedonoutputredirectiontoinsurethatfilesarenotaccidentallydestroyedandthat`>>'redirectionsrefertoexistingfiles,as
describedintheInput/outputsection.
noding
Ifset,disabletheprintingof`DING!'intheprompttimespecifiersatthechangeofhour.
noglob
Ifset,FilenamesubstitutionandDirectorystacksubstitution(q.v.)areinhibited.Thisismostusefulinshellscriptswhichdonotdealwith
filenames,orafteralistoffilenameshasbeenobtainedandfurtherexpansionsarenotdesirable.
nokanji(+)
IfsetandtheshellsupportsKanji(seetheversionshellvariable),itisdisabledsothatthemetakeycanbeused.
nonomatch
Ifset,aFilenamesubstitutionorDirectorystacksubstitution(q.v.)whichdoesnotmatchanyexistingfilesisleftuntouchedratherthancausing
anerror.Itisstillanerrorforthesubstitutiontobemalformed,e.g.,`echo['stillgivesanerror.
nostat(+)
Alistofdirectories(orglobpatternswhichmatchdirectoriesseeFilenamesubstitution)thatshouldnotbestat(2)edduringacompletionoperation.
Thisisusuallyusedtoexcludedirectorieswhichtaketoomuchtimetostat(2),forexample/afs.
notify

http://linux.about.com/library/cmd/blcmdl1_csh.htm

36/43

10/24/2015

cshLinuxCommandUnixCommand

Ifset,theshellannouncesjobcompletionsasynchronously.Thedefaultistopresentjobcompletionsjustbeforeprintingaprompt.
oid(+)
Theuser'srealorganizationID.(Domain/OSonly)
owd(+)
Theoldworkingdirectory,equivalenttothe`'usedbycdandpushd.Seealsothecwdanddirstackshellvariables.
path
Alistofdirectoriesinwhichtolookforexecutablecommands.Anullwordspecifiesthecurrentdirectory.Ifthereisnopathvariablethenonlyfullpath
nameswillexecute.pathissetbytheshellatstartupfromthePATHenvironmentvariableor,ifPATHdoesnotexist,toasystemdependentdefault
somethinglike`(/usr/local/bin/usr/bsd/bin/usr/bin.)'.Theshellmayput`.'firstorlastinpathoromititentirelydependingonhowitwascompiled
seetheversionshellvariable.Ashellwhichisgivenneitherthecnorthetoptionhashesthecontentsofthedirectoriesinpathafterreading
~/.tcshrcandeachtimepathisreset.Ifoneaddsanewcommandtoadirectoryinpathwhiletheshellisactive,onemayneedtodoarehashforthe
shelltofindit.
printexitvalue(+)
Ifsetandaninteractiveprogramexitswithanonzerostatus,theshellprints`Exitstatus'.
prompt
Thestringwhichisprintedbeforereadingeachcommandfromtheterminal.promptmayincludeanyofthefollowingformattingsequences(+),which
arereplacedbythegiveninformation:
%/
Thecurrentworkingdirectory.
%~
Thecurrentworkingdirectory,butwithone'shomedirectoryrepresentedby`~'andotherusers'homedirectoriesrepresentedby`~user'asper
Filenamesubstitution.`~user'substitutionhappensonlyiftheshellhasalreadyused`~user'inapathnameinthecurrentsession.
%c[[0]n],%.[[0]n]
Thetrailingcomponentofthecurrentworkingdirectory,orntrailingcomponentsifadigitnisgiven.Ifnbeginswith`0',thenumberofskipped
componentsprecedethetrailingcomponent(s)intheformat`/<skipped>trailing'.Iftheellipsisshellvariableisset,skippedcomponentsare
representedbyanellipsissothewholebecomes`...trailing'.`~'substitutionisdoneasin`%~'above,butthe`~'componentisignoredwhen
countingtrailingcomponents.
%C
Like%c,butwithout`~'substitution.
%h,%!,!
Thecurrenthistoryeventnumber.
%M
Thefullhostname.
%m
Thehostnameuptothefirst`.'.
%S(%s)
Start(stop)standoutmode.
%B(%b)
Start(stop)boldfacingmode.
%U(%u)
Start(stop)underlinemode.
%t,%@
Thetimeofdayin12hourAM/PMformat.
%T
Like`%t',butin24hourformat(butseetheampmshellvariable).
%p
The`precise'timeofdayin12hourAM/PMformat,withseconds.
%P
Like`%p',butin24hourformat(butseetheampmshellvariable).
\c
cisparsedasinbindkey.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

37/43

10/24/2015

cshLinuxCommandUnixCommand

^c
cisparsedasinbindkey.
%%
Asingle`%'.
%n
Theusername.
%j
Thenumberofjobs.
%d
Theweekdayin`Day'format.
%D
Thedayin`dd'format.
%w
Themonthin`Mon'format.
%W
Themonthin`mm'format.
%y
Theyearin`yy'format.
%Y
Theyearin`yyyy'format.
%l
Theshell'stty.
%L
Clearsfromtheendoftheprompttoendofthedisplayortheendoftheline.
%$
Expandstheshellorenvironmentvariablenameimmediatelyafterthe`$'.
%#
`>'(orthefirstcharacterofthepromptcharsshellvariable)fornormalusers,`#'(orthesecondcharacterofpromptchars)forthesuperuser.
%{string%}
Includesstringasaliteralescapesequence.Itshouldbeusedonlytochangeterminalattributesandshouldnotmovethecursorlocation.This
cannotbethelastsequenceinprompt.
%?
Thereturncodeofthecommandexecutedjustbeforetheprompt.
%R
Inprompt2,thestatusoftheparser.Inprompt3,thecorrectedstring.Inhistory,thehistorystring.
`%B',`%S',`%U'and`%{string%}'areavailableinonlyeightbitcleanshellsseetheversionshellvariable.
Thebold,standoutandunderlinesequencesareoftenusedtodistinguishasuperusershell.Forexample,
>setprompt="%m[%h]%B[%@]%b[%/]yourang?"
tut[37][2:54pm][/usr/accts/sys]yourang?_
If`%t',`%@',`%T',`%p',or`%P'isused,andnodingisnotset,thenprint`DING!'onthechangeofhour(i.e,`:00'minutes)insteadoftheactual
time.
Setbydefaultto`%#'ininteractiveshells.
prompt2(+)
Thestringwithwhichtopromptinwhileandforeachloopsandafterlinesendingin`\'.Thesameformatsequencesmaybeusedasinprompt(q.v.)
notethevariablemeaningof`%R'.Setbydefaultto`%R?'ininteractiveshells.
prompt3(+)
Thestringwithwhichtopromptwhenconfirmingautomaticspellingcorrection.Thesameformatsequencesmaybeusedasinprompt(q.v.)notethe
variablemeaningof`%R'.Setbydefaultto`CORRECT>%R(y|n|e|a)?'ininteractiveshells.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

38/43

10/24/2015

cshLinuxCommandUnixCommand

promptchars(+)
Ifset(toatwocharacterstring),the`%#'formattingsequenceinthepromptshellvariableisreplacedwiththefirstcharacterfornormalusersandthe
secondcharacterforthesuperuser.
pushdtohome(+)
Ifset,pushdwithoutargumentsdoes`pushd~',likecd.
pushdsilent(+)
Ifset,pushdandpopddonotprintthedirectorystack.
recexact(+)
Ifset,completioncompletesonanexactmatchevenifalongermatchispossible.
recognize_only_executables(+)
Ifset,commandlistingdisplaysonlyfilesinthepaththatareexecutable.Slow.
rmstar(+)
Ifset,theuserispromptedbefore`rm*'isexecuted.
rprompt(+)
Thestringtoprintontherighthandsideofthescreen(afterthecommandinput)whenthepromptisbeingdisplayedontheleft.Itrecognizesthesame
formattingcharactersasprompt.Itwillautomaticallydisappearandreappearasnecessary,toensurethatcommandinputisn'tobscured,andwill
appearonlyiftheprompt,commandinput,anditselfwillfittogetheronthefirstline.Ifeditisn'tset,thenrpromptwillbeprintedafterthepromptand
beforethecommandinput.
savedirs(+)
Ifset,theshelldoes`dirsS'beforeexiting.Ifthefirstwordissettoanumber,atmostthatmanydirectorystackentriesaresaved.
savehist
Ifset,theshelldoes`historyS'beforeexiting.Ifthefirstwordissettoanumber,atmostthatmanylinesaresaved.(Thenumbermustbelessthan
orequaltohistory.)Ifthesecondwordissetto`merge',thehistorylistismergedwiththeexistinghistoryfileinsteadofreplacingit(ifthereisone)
andsortedbytimestampandthemostrecenteventsareretained.(+)
sched(+)
Theformatinwhichtheschedbuiltincommandprintsscheduledeventsifnotgiven,`%h\t%T\t%R\n'isused.Theformatsequencesaredescribed
aboveunderpromptnotethevariablemeaningof`%R'.
shell
Thefileinwhichtheshellresides.Thisisusedinforkingshellstointerpretfileswhichhaveexecutebitsset,butwhicharenotexecutablebythesystem.
(SeethedescriptionofBuiltinandnonbuiltincommandexecution.)Initializedtothe(systemdependent)homeoftheshell.
shlvl(+)
Thenumberofnestedshells.Resetto1inloginshells.Seealsologinsh.
status
Thestatusreturnedbythelastcommand.Ifitterminatedabnormally,then0200isaddedtothestatus.Builtincommandswhichfailreturnexitstatus
`1',allotherbuiltincommandsreturnstatus`0'.
symlinks(+)
Canbesettoseveraldifferentvaluestocontrolsymboliclink(`symlink')resolution:
Ifsetto`chase',wheneverthecurrentdirectorychangestoadirectorycontainingasymboliclink,itisexpandedtotherealnameofthedirectory
towhichthelinkpoints.Thisdoesnotworkfortheuser'shomedirectorythisisabug.
Ifsetto`ignore',theshelltriestoconstructacurrentdirectoryrelativetothecurrentdirectorybeforethelinkwascrossed.Thismeansthatcding
throughasymboliclinkandthen`cd..'ingreturnsonetotheoriginaldirectory.Thisaffectsonlybuiltincommandsandfilenamecompletion.
Ifsetto`expand',theshelltriestofixsymboliclinksbyactuallyexpandingargumentswhichlooklikepathnames.Thisaffectsanycommand,not
justbuiltins.Unfortunately,thisdoesnotworkforhardtorecognizefilenames,suchasthoseembeddedincommandoptions.Expansionmaybe
preventedbyquoting.Whilethissettingisusuallythemostconvenient,itissometimesmisleadingandsometimesconfusingwhenitfailsto
recognizeanargumentwhichshouldbeexpanded.Acompromiseistouse`ignore'andusetheeditorcommandnormalizepath(boundbydefault
to^Xn)whennecessary.
Someexamplesareinorder.First,let'ssetupsomeplaydirectories:
>cd/tmp
>mkdirfromfrom/srcto
>lnsfrom/srcto/dst
Here'sthebehaviorwithsymlinksunset,
>cd/tmp/to/dstecho$cwd

http://linux.about.com/library/cmd/blcmdl1_csh.htm

39/43

10/24/2015

cshLinuxCommandUnixCommand
/tmp/to/dst
>cd..echo$cwd
/tmp/from
here'sthebehaviorwithsymlinkssetto`chase',
>cd/tmp/to/dstecho$cwd
/tmp/from/src
>cd..echo$cwd
/tmp/from
here'sthebehaviorwithsymlinkssetto`ignore',
>cd/tmp/to/dstecho$cwd
/tmp/to/dst
>cd..echo$cwd
/tmp/to
andhere'sthebehaviorwithsymlinkssetto`expand'.
>cd/tmp/to/dstecho$cwd
/tmp/to/dst
>cd..echo$cwd
/tmp/to
>cd/tmp/to/dstecho$cwd
/tmp/to/dst
>cd".."echo$cwd
/tmp/from
>/bin/echo..
/tmp/to
>/bin/echo".."
..
Notethat`expand'expansion1)worksjustlike`ignore'forbuiltinslikecd,2)ispreventedbyquoting,and3)happensbeforefilenamesarepassed
tononbuiltincommands.

tcsh(+)
Theversionnumberoftheshellintheformat`R.VV.PP',where`R'isthemajorreleasenumber,`VV'thecurrentversionand`PP'thepatchlevel.
term
Theterminaltype.Usuallysetin~/.loginasdescribedunderStartupandshutdown.
time
Ifsettoanumber,thenthetimebuiltin(q.v.)executesautomaticallyaftereachcommandwhichtakesmorethanthatmanyCPUseconds.Ifthereisa
secondword,itisusedasaformatstringfortheoutputofthetimebuiltin.(u)Thefollowingsequencesmaybeusedintheformatstring:
%U
Thetimetheprocessspentinusermodeincpuseconds.
%S
Thetimetheprocessspentinkernelmodeincpuseconds.
%E
Theelapsed(wallclock)timeinseconds.
%P
TheCPUpercentagecomputedas(%U+%S)/%E.
%W
Numberoftimestheprocesswasswapped.
%X
Theaverageamountin(shared)textspaceusedinKbytes.
%D
Theaverageamountin(unshared)data/stackspaceusedinKbytes.
%K
Thetotalspaceused(%X+%D)inKbytes.
%M
ThemaximummemorytheprocesshadinuseatanytimeinKbytes.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

40/43

10/24/2015

cshLinuxCommandUnixCommand

%F
Thenumberofmajorpagefaults(pageneededtobebroughtfromdisk).
%R
Thenumberofminorpagefaults.
%I
Thenumberofinputoperations.
%O
Thenumberofoutputoperations.
%r
Thenumberofsocketmessagesreceived.
%s
Thenumberofsocketmessagessent.
%k
Thenumberofsignalsreceived.
%w
Thenumberofvoluntarycontextswitches(waits).
%c
Thenumberofinvoluntarycontextswitches.
OnlythefirstfoursequencesaresupportedonsystemswithoutBSDresourcelimitfunctions.Thedefaulttimeformatis`%Uu%Ss%E%P%X+%Dk
%I+%Oio%Fpf+%Ww'forsystemsthatsupportresourceusagereportingand`%Uu%Ss%E%P'forsystemsthatdonot.
UnderSequent'sDYNIX/ptx,%X,%D,%K,%rand%sarenotavailable,butthefollowingadditionalsequencesare:
%Y
Thenumberofsystemcallsperformed.
%Z
Thenumberofpageswhicharezerofilledondemand.
%i
Thenumberoftimesaprocess'sresidentsetsizewasincreasedbythekernel.
%d
Thenumberoftimesaprocess'sresidentsetsizewasdecreasedbythekernel.
%l
Thenumberofreadsystemcallsperformed.
%m
Thenumberofwritesystemcallsperformed.
%p
Thenumberofreadsfromrawdiskdevices.
%q
Thenumberofwritestorawdiskdevices.
andthedefaulttimeformatis`%Uu%Ss$E%P%I+%Oio%Fpf+%Ww'.NotethattheCPUpercentagecanbehigherthan100%onmultiprocessors.
tperiod(+)
Theperiod,inminutes,betweenexecutionsoftheperiodicspecialalias.
tty(+)
Thenameofthetty,oremptyifnotattachedtoone.
uid(+)
Theuser'srealuserID.
user
Theuser'sloginname.
verbose
Ifset,causesthewordsofeachcommandtobeprinted,afterhistorysubstitution(ifany).Setbythevcommandlineoption.

http://linux.about.com/library/cmd/blcmdl1_csh.htm

41/43

10/24/2015

cshLinuxCommandUnixCommand

version(+)
TheversionIDstamp.Itcontainstheshell'sversionnumber(seetcsh),origin,releasedate,vendor,operatingsystemandmachine(seeVENDOR,
OSTYPEandMACHTYPE)andacommaseparatedlistofoptionswhichweresetatcompiletime.Optionswhicharesetbydefaultinthedistributionare
noted.
8b
Theshelliseightbitcleandefault
7b
Theshellisnoteightbitclean
nls
Thesystem'sNLSisuseddefaultforsystemswithNLS
lf
Loginshellsexecute/etc/csh.loginbeforeinsteadofafter/etc/csh.cshrcand~/.loginbeforeinsteadofafter~/.tcshrcand~/.history.
dl
`.'isputlastinpathforsecuritydefault
nd
`.'isomittedfrompathforsecurity
vi
vistyleeditingisthedefaultratherthanemacs
dtr
LoginshellsdropDTRwhenexiting
bye
byeisasynonymforlogoutandlogisanalternatenameforwatchlog
al
autologoutisenableddefault
kan
Kanjiisusedifappropriateaccordingtolocalesettings,unlessthenokanjishellvariableisset
sm
Thesystem'smalloc(3)isused
hb
The`#!<program><args>'conventionisemulatedwhenexecutingshellscripts
ng
Thenewgrpbuiltinisavailable
rh
TheshellattemptstosettheREMOTEHOSTenvironmentvariable
afs
Theshellverifiesyourpasswordwiththekerberosserveriflocalauthenticationfails.TheafsusershellvariableortheAFSUSERenvironment
variableoverrideyourlocalusernameifset.
Anadministratormayenteradditionalstringstoindicatedifferencesinthelocalversion.
visiblebell(+)
Ifset,ascreenflashisusedratherthantheaudiblebell.Seealsonobeep.
watch(+)
Alistofuser/terminalpairstowatchforloginsandlogouts.Ifeithertheuseris`any'allterminalsarewatchedforthegivenuserandviceversa.Setting
watchto`(anyany)'watchesallusersandterminals.Forexample,
setwatch=(georgettyd1anyconsole$userany)
reportsactivityoftheuser`george'onttyd1,anyuserontheconsole,andoneself(oratrespasser)onanyterminal.
Loginsandlogoutsarecheckedevery10minutesbydefault,butthefirstwordofwatchcanbesettoanumbertocheckeverysomanyminutes.
Forexample,
setwatch=(1anyany)

http://linux.about.com/library/cmd/blcmdl1_csh.htm

42/43

10/24/2015

cshLinuxCommandUnixCommand
reportsanylogin/logoutonceeveryminute.Fortheimpatient,thelogbuiltincommandtriggersawatchreportatanytime.Allcurrentloginsare
reported(aswiththelogbuiltin)whenwatchisfirstset.
Thewhoshellvariablecontrolstheformatofwatchreports.

who(+)
Theformatstringforwatchmessages.Thefollowingsequencesarereplacedbythegiveninformation:
%n
Thenameoftheuserwhologgedin/out.
%a
Theobservedaction,i.e.,`loggedon',`loggedoff'or`replacedolduseron'.
%l
Theterminal(tty)onwhichtheuserloggedin/out.
%M
Thefullhostnameoftheremotehost,or`local'ifthelogin/logoutwasfromthelocalhost.
%m
Thehostnameoftheremotehostuptothefirst`.'.ThefullnameisprintedifitisanIPaddressoranXWindowSystemdisplay.
%Mand%mareavailableononlysystemsthatstoretheremotehostnamein/etc/utmp.Ifunset,`%nhas%a%lfrom%m.'isused,or`%nhas%a
%l.'onsystemswhichdon'tstoretheremotehostname.
wordchars(+)
Alistofnonalphanumericcharacterstobeconsideredpartofawordbytheforwardword,backwardwordetc.,editorcommands.Ifunset,`*?_.[]~='
isused.

SEEALSO
csh(1),emacs(1),ls(1),newgrp(1),sh(1),setpath(1),stty(1),su(1),tset(1),vi(1),x(1),access(2),execve(2),fork(2),killpg(2),pipe(2),setrlimit(2),sigvec(2),
stat(2),umask(2),vfork(2),wait(2),malloc(3),setlocale(3),tty(4),a.out(5),termcap(5),environ(7),termio(7),IntroductiontotheCShell

Important:Usethemancommand(%man)toseehowacommandisusedonyourparticularcomputer.
>>Linux/UnixCommandLibrary
>>ShellCommandLibrary

http://linux.about.com/library/cmd/blcmdl1_csh.htm

43/43

Você também pode gostar