CS 279 - Week 13 Lecture 2 - 11-15-12
* we've used let for arithmetic computations;
* expr can also be used for these, (and for some
other operations as well)
expr <expr>
* <expr> is made up of "words" <-- value,
operator, or parenthesis
* words MUST be separated by white space
* characters meaningful to the shell
must be escaped
* must quote null strings and strings
containing blanks
* comparisons: < > <= >= != ==
logical operations:
expr1 | expr2
* if expr1 is neither null or zero,
result is expr1; otherwise,
it is expr2
expr1 & expr2
* if neither expr1 nor expr2 is null
or zero, result is expr1; otherwise
it is zero
* you can also do pattern matching:
expr1 : expr2
* treats expr1 as a string and
treats expr2 as a BRE (basic
regular expression), returns
the number of characters matched,
or 0 if the match failed
(ONE subexpression is allowed,
if used, the matching substring
is returned)
bc - on-line calculator
* pp. 280-286 talks about preloading functions
and other goodies
* ^d or quit to quit
* you can pipe an expression to it!
(echo the expression...
echo "3*4" | bc
sleep
* do nothing for a specified number of
seconds
sleep 5
* demo'd in beeper.sh
time
* gives you the real time, user time,
and system time that it took to run
a command
wait
* wait until the specified process id
completes to go on
wait 4604 # 4604 is a process id
nohup - "no hangup"
* execute a command in such a way
that it continues to execute even if you
log off or disconnect your terminal
"hang up"
remember the &
* (use
ps x
to see that the process is still running
when its terminal is closed)
nice
* run something at a lower priority
than it would normally get
nice [-n num] <cmd>
number is expected to be 1-19 (acc to
course text), it adds that to the
process's priority (and bigger numbers
are lower priority)
renice lets you lower the priority of
a running process --
renice [-n number] [-p <process-id>]