Flylib.com

Books Software

 
 
 

Job Names

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents
Chapter 5.  Job Control


Job Names

Most people use the job number to refer to a job, because one number is easy to remember. However, jobs can be referred to in a number of other ways: by process id, current/previous job, or all or part of a job name . If we had these jobs:


$ jobs l


[3]  + 466 Stopped          split ?000 hugefile


[2]  ?465 Running          find / name  print &


[1]    463 Running          sleep 25 &

then the split job could be referred to as %3 , %+ , %% , 466 , %split , or %?sp , the find job could be referred to as %2 , %?/span>, 465 , %find , or %?f , and the sleep could be referred to as %1 , 463 , %sleep , or %?sl .

Table 5.2. Job Names

% n

job n

%+ , %%

current job

%?/span>

previous job

% string

job whose name begins with string

%? string

job that matches part or all of string


   
Top
 

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents
Chapter 5.  Job Control


Leaving Stopped Jobs

The Korn shell displays a warning message if you try to exit from the shell while jobs are stopped.


$ stty tostop


$ date &


[1]   541


[1] + Stopped(tty output)      date &


$ exit


You have stopped jobs

If you ignore this message and exit, the Korn shell will not attempt to warn you again and any stopped jobs will be terminated .


   
Top
 

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents


Chapter 6. Performing Arithmetic

The let Command

The ((...)) Command

Declaring Integer Variables

Arithmetic Constants

Arithmetic Operators

Random Numbers

The Korn shell provides the ability to perform integer arithmetic in any base from two to thirty-six using built-in commands. It executes much faster than using the expr command, since it doesn't have to start another process. It can also be used instead of the test command for integer comparisons. In addition, all of the operators from the C programming language (except ++ , -- , and ?: ) are now supported by the Korn shell.


   
Top
 

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents
Chapter 6.  Performing Arithmetic


The let Command

Integer arithmetic can be done with the let command and arithmetic expressions. The format for the let command is:


let "


arithmetic-expression


"

where arithmetic-expressions can contain constants, operators, and Korn shell variables . Double quotes are used with arithmetic expressions that contain white space or operators that have special meaning to the Korn shell. For example, variable X can be set to the sum of 1+1 like this:


$ let "X=1 + 1"


$ print $X


2

then incremented:


$ let "X=X + 1"


$ print $X


3

Notice that in arithmetic expressions, regular variables can be referenced by name only, and do not have to be preceded by $ for substitution to be performed. Both


$ let "X=X + 1"

and


$ let "X=$X + 1"

are equivalent. The first format is preferred because parameter expansion does not have to be performed. This causes it to be executed faster.

Table 6.1. Arithmetic Operators (in order of precedence)

?/P>

unary minus

!

logical negation

~

bitwise negation

*, /, %

multiplication, division, remainder (modulo)

+, ?/P>

addition, subtraction

<<, >>

left shift, right shift

<=, <

less than or equal to, less than

>=, >

greater than or equal to, greater than

==

equal to

!=

not equal to

&

bitwise AND

^

bitwise exclusive OR

bitwise OR

&&

logical AND

logical OR

=

assignment

*=, /=, %=

multiply assign, divide assign, modulo assign

+=, ?

increment, decrement

<<=, >>=

left shift assign, right shift assign

&=, ^=, =

bitwise AND assign, bitwise exclusive OR assign, bitwise OR assign

(...)

grouping (used to override precedence rules)

Arithmetic expressions are made up of constants, variables or any of the arithmetic operators in Table 6.1.


   
Top