linux Variables --------------------------------------------------
Variable substitution
Variable modifiers
Predefined shell factors
Arranging for the provoke variable
Test .cshrc record
Condition factors
8.4.1. Variable Substitution
In the accompanying substitutions, props ({}) are discretionary, aside from when expected to isolate a variable name from following characters that would somehow be viewed as a component of the name:
Variable Description
${var} The estimation of variable var.
${var[i]}
Select word or words in position I of var. I can be a solitary number, a range m-n, a range - n (missing m suggests 1), a range m-(missing n infers every single outstanding word), or * (select all words). I additionally can be a variable that extends to one of these qualities.
${#var} The number of words in var.
${#argv} The number of contentions.
$0 Name of the program.
${argv[n]}
Singular contentions on order line (positional parameters); 1 n 9.
${n}
Same as ${argv[n]}.
${argv[*]} All contentions on order line.
$* Same as {$argv[*]}.
$argv[$#argv] The last contention.
${?var}
Return 1 if var is set, 0 if var isn't set.
$$
Process number of current shell; helpful as a major aspect of a filename for making brief records with one of a kind names.
${?name} Return 1 if name is set, 0 if not.
$?0 Return 1 whenever info filename is known, 0 if not.
8.4.1.1. Precedents
Deal with the third last contentions and spare the yield in a document whose name is exceptional to this procedure:
sort $argv[3-] > tmp.$$
Process .cshrc directions just if the shell is intuitive (i.e., the provoke variable must be set):
in the event that ($?prompt)
set directions,
false name directions,
and so on.
endif
8.4.2. Variable Modifiers
With the exception of $?var, $$, and $?0, the variable substitutions in the previous segment might be trailed by one of these modifiers (when props are utilized, the modifier goes inside them):
:r
Restore the variable's root (the segment before the last speck).
:e
Restore the variable's augmentation.
:h
Restore the variable's header (the catalog partition).
:t
Restore the variable's tail (the segment after the last cut).
:gr
Restore all roots.
:ge
Restore all augmentations.
:gh
Restore all headers.
:gt
Restore all tails.
:q
Statement a wordlist variable, keeping the things independent. Helpful when the variable contains filename metacharacters that ought not be extended.
:x
Statement an example, growing it into a wordlist.
8.4.2.1. Models utilizing pathname modifiers
The accompanying table demonstrates the utilization of pathname modifiers on the accompanying variable:
set aa=(/progs/num.c/book/chap.ps)
Variable Portion Specification Output Result
Typical variable echo $aa /progs/num.c/book/chap.ps
Second root echo $aa[2]:r /book/chap
Second header echo $aa[2]:h /book
Second tail echo $aa[2]:t chap.ps
Second extension echo $aa[2]:e ps
Root echo $aa:r /progs/num/book/chap.ps
Worldwide root echo $aa:gr /progs/num/book/chap
Header echo $aa:h /progs/book/chap.ps
Worldwide header echo $aa:gh /progs/book
Tail echo $aa:t num.c/book/chap.ps
Worldwide tail echo $aa:gt num.c chap.ps
Extension echo $aa:e c/book/chap.ps
Worldwide extension echo $aa:ge c ps
8.4.2.2. Precedents utilizing citing modifiers
Except if cited, the shell extends factors to speak to documents in the present index:
% set a="[a-z]*" A="[A-Z]*"
% resound "$a" "$A"
[a-z]* [A-Z]*
% reverberate $A
at cc m4 Book Doc
% reverberate $a:x $A
[a-z]* Book Doc
% set d=($a:q $A:q)
% reverberate $d
at cc m4 Book Doc
% resound $d:q
[a-z]* [A-Z]*
% resound $d[1] +++ $d[2]
at cc m4 +++ Book Doc
% resound $d[1]:q
[a-z]*
8.4.3. Predefined Shell Variables
Factors can be set in one of two different ways, by doling out an esteem:
set var=value
or then again by basically turning the variable on:
set var
In the accompanying rundown, factors that acknowledge values are given with the equivalents hint pursued by the kind of significant worth they acknowledge; the esteem at that point is portrayed. (Note, nonetheless, that factors, for example, argv, cwd, or status are never expressly allocated.) For factors that are killed on or, the table depicts what they do when set. tcsh naturally sets (and, at times, refreshes) the factors addsuffix, argv, autologout, cwd, dirstack, reverberate style, alter, gid, home, loginsh, logout, oid, owd, way, incite, prompt2, prompt3, shell, shlvl, status, tcsh, term, tty, uid, client, and rendition. Factors in italics are explicit to tcsh.
Variable Description
addsuffix
Affix/to registries and a space to documents amid tab finishing to demonstrate an exact match.
ampm Display all occasions in 12-hour organize.
argv=(args)
Rundown of contentions go to current order; default is ().
autocorrect
Check spelling before endeavoring to finish directions.
autoexpand
Extend history, (for example, ! references) amid direction finishing.
autolist[=ambiguous]
Print conceivable consummations when right one is questionable. On the off chance that vague is indicated, print conceivable consummations just when finish includes no new characters.
autologout=logout-minutes [locking-minutes]
Log out after logout-minutes of inactive time. Bolt the terminal subsequent to locking-minutes of inactive time, requiring a secret phrase before proceeding. Not utilized if the DISPLAY condition variable is set.
backslash_quote Always permit oblique punctuation lines to cite \, ', and <">.
cdpath=dirs
Rundown of interchange registries to look when finding contentions for disc, popd, or pushd.
shading
Turn on shading for ls-F, ls, or both. Setting to nothing is proportional to setting for both.
order
Whenever set, holds the order go to the shell with the - c alternative.
complete=enhance
Whenever improve, disregard case in finish, treat ., - , and _ as word separators, and consider _ and - to be the equivalent.
correct={cmd|complete|all}
Whenever cmd, spellcheck directions. Whenever complete, total directions. Whenever all, spellcheck entire order line.
cwd=dir Full pathname of current index.
dextract
Whenever set, the pushd order removes the ideal catalog and puts it at the highest point of the stack, rather than turning the stack.
dirsfile=file
History record counseled by dirs - S and dirs - L. Default is ~/.cshdirs.
dirstack
Registry stack, in cluster organize. dirstack[0] is constantly proportional to cwd. Alternate components can be misleadingly changed.
dspmbyte=code
Empower utilization of multibyte code; for use with Kanji. See the tcsh manpage for subtleties.
dunique
Ensure that every catalog exists just once in the stack.
resound
Redisplay each order line before execution; same as csh - x direction.
echo_style={bsd|sysv|both|none}
Try not to resound a newline with - n alternative (bsd) | parse got away characters (sysv) | do both | do not one or the other.
edit Enable order line editorial manager.
ellipsis
For use with provoke variable. Speak to skipped catalogs with ....
fignore=chars
Rundown of filename additions to overlook amid filename fulfillment (see filec).
filec
Whenever set, a filename that is in part composed on the order line can be extended to its full name when Esc is squeezed. On the off chance that more than one filename would coordinate, type EOF to list conceivable fulfillments. Disregarded in tcsh.
gid User's gathering ID.
gathering
Client's gathering name.
histchars=ab
A two-character string that sets the characters to use ever substitution and snappy substitution (default is !^).
histdup={all|prev}
Keep up a record just of exceptional history occasions (all), or don't enter new occasion when it is equivalent to the past one (prev).
histfile=file
History record counseled by history - S and history - L. Default is ~/.history.
histlit
Try not to grow history lines while reviewing them.
history=n arrange
The primary word shows the quantity of directions to spare in the history list. The second shows the organization with which to show that rundown (tcsh just; see the incite segment for conceivable configurations).
home=dir
Home registry of client, instated from HOME. The ~ character is shorthand for this esteem.
ignoreeof
Overlook a finish of-record (EOF) from terminals; averts unplanned logout.
implicitcd
On the off chance that registry name is entered as an order, album to that catalog. Can be set to verbose to resound the cd to standard yield.
inputmode={insert|overwrite}
Control supervisor's mode.
listflags=flags
At least one of the x, an, or A choices for the ls-F worked in order. Second word can be set to way for ls direction.
listjobs=long
At the point when a vocation is suspended, list all employments (in long organization, whenever indicated).
listlinks
In ls - F direction, incorporate kind of record to which joins point.
listmax=num
Try not to permit list-decisions to print more than num decisions before provoking.
listmaxrows=num
Try not to permit list-decisions to print more than num columns of decisions before inciting.
loginsh Set if shell is a login shell.
logout
Demonstrates status of an approaching logout (typical, programmed, or hangup).
mail=(n documents)
At least one documents checked for new mail at regular intervals or (if n is provided) each n seconds.
matchbeep={never|nomatch|ambiguous|notunique}
Indicates conditions under which finishing should blare: never, if no match exists, if numerous matches exist, or if different matches exist and one is correct.
nobeep Disable signaling.
noclobber
Try not to divert yield to a current record; counteracts coincidental devastation of documents.
noglob
Kill filename extension; helpful in shell contents.
nokanji Disable Kanji (whenever upheld).
nonomatch
Treat filename metacharacters as exacting characters, if no match exists (e.g., vi ch* makes new document ch* as opposed to printing "No match").
nostat=directory-list
Don't detail catalog list amid consummation.
notify Declare work consummations when they happen.
owd Old working registry.
path=(dirs)
Rundown of pathnames in which to scan for directions to execute. Instated from PATH; the default is: . /usr/ucb/usr/receptacle
printexitvalue Print all nonzero leave esteems.
prompt='str'
0 Comments
Post a Comment