# lists jobs in current session $ jobs # start job 1 (sleeps for 200 seconds) $ sleep 200 # suspended job 1 using control-z  + Stopped sleep 200 # start job 2 (sleeps for 400 seconds) $ sleep 400 # suspended job 2 using control-z  + Stopped sleep 400 # lists jobs in current session shows the jobs are suspended i.e. not … Continue reading process control
There are multiple ways to place a program in background mode. Background mode is when the program runs and returns you the prompt back and the program is till running but it can be tied to the session or untied to the shell. The following scenario is when a process is tied to a shell: Example: $ sleep 60 & In the above example you … Continue reading Background process
— Get process id of current process $ echo $$ 6113 — shows process id $ ps PID TTY TIME CMD 2050 pts/2 00:00:00 ps 6113 pts/2 00:00:00 ksh Useful when creating a unique temp file example TEMPFILE=/tmp/tmpfile.$$ — Get process id of last background id $ sleep 10 &  2078 $ echo $! 2078 — Print parent process id $ print $PPID 6048 Continue reading ksh – Process
C-shell (csh) Example: set prompt=”[%n@%m %c] \! %” oracle@localhost ~] 39 % In this above example sets prompt to display username, hostname, current working directory and history number. %n – username, %m – hostname, %c – pwd, \! – history number K-shell (ksh) Example: $ export PS1=’$USER [$PWD] $ ‘ oracle [/home] $ In the above example, sets prompt to display username and current working … Continue reading How to change unix prompt?
Using the following script it will find all version of a command in $PATH (from Unix Power Tools) $ cat /tmp/whereiz #!/bin/sh testx=”test -x” fixpath=”`echo $PATH | sed \ -e 's/^:/.:/' \ -e 's/::/:.:/g' \ -e 's/:$/:./'`” # echo $fixpath IFS=”: ” for command do where=”” for direc in $fixpath do $testx $direc/$command && where=”$where $direc/$command” done case “$where” in ?*) echo $where ;; esac … Continue reading whereiz – find all version of a command
By setting trap one can run a logout script when a k-shell is being terminated. The built-in command trap in k-shell allows one to customize shell when a signal is received. # Set to run $HOME/.logout script when shell is terminated $ trap ‘. $HOME/.logout’ 0 # display list of signals setup $ trap trap — ‘. $HOME/.logout’ EXIT Continue reading Run a logout script in k-shell
Here are some of the options that can be passed to grep: -l – Print filename if pattern found otherwise it doesn’t print the filename, if found any one file exit status is 0, if not found in any files then 1 -n – Print line # where pattern was found -i – ignore case when matching string -v – Display lines where the given … Continue reading grep options