Pages

Friday, May 29, 2009

My bin

dd -

#!/bin/csh -f
#-------------------------------------------------------------------------------
set parm = 'ls -l'

while (1)
if ($1 == '/od') then
if ($?bysize) then
echo 'Error: cannot sort by both date & size'
exit(1)
else
set bydate = '-t -r'
endif
else
if ($1 == '/os') then
if ($?bydate) then
echo 'Error: cannot sort by both date & size'
exit(1)
else
set bysize = 'sort -n -k 5'
endif
else
if ($1 == '/r') then
set revse = '-r'
else
if ($1 == '/a') then
set hidden = '-a'
else
break
endif
endif
endif
endif
shift
end

#---------------------------------------------------------------------------
if ($?hidden) then
set parm = "$parm $hidden"
endif

if ($?bydate) then
set parm = "$parm $bydate"
endif

if ($?bysize) then
$parm $* | $bysize | more -e
else
$parm $* | more -e
endif

exit(0);



gr -

#!/bin/ksh


# this script greps Process

if [ $1'x' = 'x' ]; then
echo 'Nothing to grep'
exit 1
fi

flag=ef

while getopts :c:l args
do
case $args in

c) clear
shift
;;

l) flag=fL
shift
;;

esac
done

if [ $flag == "ef" ]; then
echo "tracing process by name >>>> ps -ef | grep $* "

ps -ef | grep $* | grep -v ~djen/bin/gr | grep -v grep
else

echo "tracing single process tree >>>> ps -fL "

ps -fL $*
fi


path -

#!/bin/ksh
#-------------------------------------------------------------------------------

if [ $# -eq 0 ]; then

echo $PATH | tr ':' '\n'

else

set -A arPATH `echo $PATH | tr ':' ' '`

idx=0
while [ $idx -lt ${#arPATH[*]} ]
do
if [ -f ${arPATH[idx]}/$1 ]; then
ls -l ${arPATH[idx]}/$1
break
else
((idx=idx+1))
fi
done

fi