process control

# lists jobs in current session $ jobs # start job 1 (sleeps for 200 seconds) $ sleep 200 # suspended job 1 using control-z [1] + Stopped sleep 200 # start job 2 (sleeps for 400 seconds) $ sleep 400 # suspended job 2 using control-z [2] + Stopped sleep 400 # lists jobs…

Background process

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:…

ksh – 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 & [1] 2078 $ echo $!…

How to change unix prompt?

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…

whereiz – find all version of a command

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…

Run a logout script in k-shell

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…

grep options

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…