Need help in a simple shell script

Hi All

I have requirement to write a shell script which would look for the userid which is logged in , and once the User id is found i would delete certain
lines from a parameter file ..

here is what iam using

a=ps -o user | grep -v user | uniq

then using an if condition and moving on

can anyone tell me what is the bug it is not able to find the instance name ..

can anyone help me on this

This is my sample thing i am doing (very Simple)

a=ps -o user | grep -v user | uniq #instance name is cool

a = ps -o user | grep -v USER | uniq
if [ "$a" = "cool" ];then
echo " This is cool"
else
echo " Not Equal"
fi

Please help me on this

Thanks !!!!

Just by looking at it, when you set the a variable it should be:

a=`ps -o user | grep -v USER | uniq`

You need to quote out stuff, also run the script as a bourne shell script

#! /bin/sh
aa=`ps -o user | grep -v USER | uniq`
if [ ${aa} = "cool" ] ; then
echo "${aa} is cool"
...

Try looking at SED or Ed to delete lines in a file within the test statement,
though someone else might have a easier way.

To store the output of a command in a variable, use command substitution:

a=$( ps -o user | grep -v USER | uniq )

You don't need grep or uniq:

case $( ps -o user ) in
     *USER*) echo "alcool" ;;
     *) echo "uncool" ;;
esac

However, you probably should use who or w to determine whether someone is logged in.

Thanks all guys it worked ..