Paramete Meaning
r
$# The number of arguments passed to the program; or the number of parameters set
by executing the set statement
$* Collectively references all the positional parameters as $1, $2, ...
$@ Same as $*, except when double-quoted ("$@") collectively references all the
positional parameters as "$1", "$2", ...
$0 The name of the program being executed
$$ The process id number of the program being executed
$! The process id number of the last program sent to the background for execution
$? The exit status of the last command not executed in the background
$- The current option flags in effect
Table 10.1. echo Escape Characters
Characte Prints
r
\b Backspace
\c The line without a terminating newline
\f Formfeed
\n Newline
\r Carriage return
\t Tab character
\\ Backslash character
\0nnn The character whose ASCII value is nnn, where nnn is a one- to three-digit octal
number
Symbol/command Meaning/action
> Redirect output.
>> Append to file.
< Redirect input.
<< "Here" document (redirect input).
| Pipe output.
& Run process in background.
; Separate commands on same line.
~ Home directory symbol.
* Match any character(s) in filename.
? Match single character in filename.
[ ] Match any characters enclosed.
( ) Execute in subshell.
{ } Expand elements in list.a
' ' Substitute output of enclosed command.
" " Partial quote (allows variable and command expansion).
' ' Full quote (no expansion).
\ Quote following character.
$var Use value for variable.
$$ Process ID.
$0 Command name.
$n
n th argument (0 n 9).
$* All arguments as simple words.
# Begin comment.
bg Background execution.
break Break from loop statements.
cd Change directory.
Symbol/command Meaning/action
continue Resume a program loop.
echo Display output.
eval Evaluate arguments.
exec Execute a new shell.
fg Foreground execution.
history List previous commands.
jobs Show active jobs.
kill Terminate running jobs.
shift Shift positional parameters.
suspend Suspend a foreground job (such as a shell created by su).
time Time a command.
umask Set default file permissions for new files.
unset Erase variable or function definitions.
wait Wait for a background job to finish
The following table displays features that are different among the three shells.
bash ksh tcsh Meaning/action
$ $ % Prompt.
>| >| >! Force redirection.
>>! Force append.
> file 2>&1 > file 2>&1 >& file Combine stdout and stderr.
>& file >& file Combine stdout and stderr.
' ' ' ' ' ' Substitute output of enclosed command.
$( ) $( )
Substitute output of enclosed command.
(Preferred form.)
bash ksh tcsh Meaning/action
$HOME $HOME $home Home directory.
var=value var=value set var=value Variable assignment.
export export setenv var
var=val var=val val Set environment variable.
${nn} ${nn} More than nine args can be referenced.
"$@" "$@" All args as separate words.
$# $# $#argv Number of arguments.
$? $? $status Exit status.
$! $! Last background Process ID.
$- $- Current options.
.file .file source file Read commands in file.
alias x=y alias x=y alias x y Name x stands for y.
case case switch/case Choose alternatives.
cd ~- cd ~- popd/pushd Switch directories.
popd/pushd popd/pushd Switch directories.
done done end End a loop statement.
esac esac endsw End case or switch.
exit
exit [n] exit [n]
[(expr)] Exit with a status.
for/do for/do foreach Loop through values.
echo -E print -r glob Ignore echo escapes.
hash alias -t hashstat Display hashed commands (tracked aliases).
alias -t
hash cmds
cmds
rehash Remember command locations.
hash -r PATH=$PATH unhash Forget command locations.
history history history List previous commands.
fc -s r !! Redo previous command.
fc -s str r str !str Redo command that starts with str.
fc -s x=y r x=y [cmd] !cmd:s/x/y/ Edit command, then execute.
bash ksh tcsh Meaning/action
[cmd]
if ((i==5)) if ((i==5)) if ($i==5) Sample if statement.
fi fi endif End if statement.
ulimit ulimit limit Set resource limits.
pwd pwd dirs Print working directory.
read read $< Read from standard input.
trap INTR TRap INTR onintr Ignore interrupts.
unalias unalias unalias Remove aliases.
until/do until/do Begin until loop.
while/do while/do while Begin while loop.
Filename Metacharacters
* Match any string of zero or more characters.
? Match any single character.
Match any one of the enclosed characters; a hyphen can specify a range (e.g., a-z, A-
[abc...]
Z, 0–9).
[!abc...] Match any character not enclosed as above.
~ Home directory of the current user.
~name Home directory of user name.
~+ Current working directory ($PWD).
~- Previous working directory ($OLDPWD).
Class Characters matched Class Characters matched
alnum Alphanumeric characters graph Nonspace characters
alpha Alphabetic characters print Printable characters
blank Space or tab punct Punctuation characters
cntrl Control characters space Whitespace characters
digit Decimal digits upper Uppercase characters
lower Lowercase characters xdigit Hexadecimal digits
Bash and ksh93 also accept the [:word:] character class, which is not in POSIX. [[:word:]] is
equivalent to [[:alnum:]_].
[Link]. Examples
$ ls new* List new and new.1
$ cat ch? Match ch9 but not ch10
$ vi [D-R ]* Match files that begin with uppercase D through R
$ pr !(*.o|core) | lp Print files that are not object files or core
dumps
-------------------------------------------------------------------------------------------------------------------------------------------
--
#!/bin/ksh
. [Link]
echo "Start time store `date`"
echo "Start time of PRIME_RX_FACILITY and DISABLE_CONST_INDEX => `date` "
sqlplus << EOF
${DB_LOGIN}
VARIABLE v_job_id NUMBER
BEGIN
SELECT sq_store_cutout_log.nextval INTO :v_job_id FROM DUAL;
--
delete from trexone_data.cutout_facility;
insert into trexone_data.cutout_facility values (${1});
commit;
--
store_cutout_m.PRIME_RX_FACILITY( :v_job_id, ${1} );
--store_cutout_m.DISABLE_CONST_INDEX( :v_job_id, ${1});
DISABLE_CONST_INDEX( :v_job_id, ${1});
END;
EXIT :v_job_id
EOF
# Get the JOB ID and process id from the last process and pass it to all of the
# other cutout processes
JOB_ID=$?
echo JOB ID = ${JOB_ID}
PROCESS_ID=$$
echo PROCESS_ID = ${PROCESS_ID}
echo "Stop time of PRIME_RX_FACILITY and DISABLE_CONST_INDEX => `date` "
# temporarily
sqlplus << EOF
${DB_LOGIN}
truncate table trexone_cutout001.store_cutout_log;
EXIT
EOF
echo "Start time package part of store `date`"